Skip to main content

A tiny Python library to create and train feedforward neural networks

Project description

<p align="center">
<img src="">

# NNWeaver #

[![Coverage Status](](
[![Build Status](](

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:

1. Simple API, easy to learn.
2. Validation functions included.
3. Lightweight and with few dependencies.
4. Live loss/epoch curve display.

## Installation ##

You can install NNWeaver from the GitHub source with the following commands:

git clone
cd nnweaver
python3 install

You can also run the test suite with `python3 test`.

## Getting started ##

### Specify a Neural Network Topology ###

You can create a feedforward neural network specifying the number of inputs as the argument of [`NN`](, and the number of outputs by adding a [`Layer`](

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()))

See [`activations`]( for the list of available activation functions.

### Train the Neural Network ###

Now, choose a [`Loss`]( function, pass it to an [`Optimizer`]( (like the stochastic gradient descent) and start the training:

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)

Also, you may want to control the model complexity. [`SGD.train()`]( has a `regularizer` argument, that accepts an instance of the [`L1L2Regularizer`]( class.

### A very, very simple example ###

<img src="" width="550" />

## Documentation ##

For more information, tutorials, and API reference, please visit [NNweaver's online documentation]( or build your own offline copy executing `python3 docs`.

## License ##

This project is licensed under the terms of the MIT License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nnweaver, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size nnweaver-0.2-py3-none-any.whl (18.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nnweaver-0.2.tar.gz (15.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page