NNWeaver is a tiny Python library to create and train feedforward neural networks. We developed this library as a project for a Machine Learning course.
Some of its features are:
- Simple API, easy to learn.
- Validation functions included.
- Lightweight and with few dependencies.
- Live loss/epoch curve display.
You can install NNWeaver from the GitHub source with the following commands:
git clone https://github.com/gvinciguerra/nnweaver.git cd nnweaver python3 setup.py install
You can also run the test suite with
python3 setup.py test.
Specify a Neural Network Topology
from nnweaver import * nn = NN(3) nn.add_layer(Layer(5, Linear))
You can always add more layers, specify an activation function and a weights initializer, as the following lines of code show:
nn.add_layer(Layer(7, Sigmoid)) nn.add_layer(Layer(6, Rectifier, uniform(0, 0.05))) nn.add_layer(Layer(42, TanH, glorot_uniform()))
activations for the list of available activation functions.
Train the Neural Network
sgd = SGD(MSE) sgd.train(nn, x, y, learning_rate=0.3)
There are other arguments to pass to the
SGD.train() method, for example:
sgd.train(nn, x_train, y_train, learning_rate_time_based(0.25, 0.001), batch_size=10, epochs=100, momentum=0.85)
A very, very simple example
For more information, tutorials, and API reference, please visit NNweaver's online documentation or build your own offline copy executing
python3 setup.py docs.
This project is licensed under the terms of the MIT License.