Recently, I used PyBrain, a machine learning library for Python, to build and train neural networks. With PyBrain, it's fairly easy to build a neural network, and you can export the trained model as an xml file. Of course, if you read this, you can reuse the model.
So, this time I will summarize the installation method and writing / loading the model.
Use pip for installation.
pip install pybrain
Use from pybrain.tools.xml import NetworkWriter
.
from pybrain.tools.shortcuts import buildNetwork
# ~Omission(Reading training data, etc.) ~
#Definition of neural network model
network = buildNetwork(64, 19, 2)
# ~Omission (perform training using data)~
#Export the model
NetworkWriter.writeToFile(network, 'model.xml')
This will output a file called model.xml with the settings of the trained model.
Use from pybrain.tools.xml import Network Reader
.
from pybrain.tools.xml import NetworkReader
network = NetworkReader.readFrom('model.xml')
By reading the model.xml output earlier, the trained model can be reproduced.
After that, please recognize it, learn more, or like it.
Recommended Posts