<img src="https://gvinciguerra.github.io/nnweaver/_static/logo.svg">
</p>
# NNWeaver #
[](https://coveralls.io/github/gvinciguerra/nnweaver?branch=master)
[](https://travis-ci.org/gvinciguerra/nnweaver)
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 https://github.com/gvinciguerra/nnweaver.git
cd nnweaver
python3 setup.py install
You can also run the test suite with `python3 setup.py 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`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.nn.NN), and the number of outputs by adding a [`Layer`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.nn.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`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#module-nnweaver.activations) for the list of available activation functions.
### Train the Neural Network ###
Now, choose a [`Loss`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.losses.Loss) function, pass it to an [`Optimizer`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.optimizers.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()`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.optimizers.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()`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.optimizers.SGD.train) has a `regularizer` argument, that accepts an instance of the [`L1L2Regularizer`](https://gvinciguerra.github.io/nnweaver/nnweaver.html#nnweaver.regularizers.L1L2Regularizer) class.
### A very, very simple example ###
<img src="https://github.com/gvinciguerra/nnweaver/blob/gh-pages/_images/nnweaver.gif?raw=true" width="550" />
## Documentation ##
For more information, tutorials, and API reference, please visit [NNweaver's online documentation](https://gvinciguerra.github.io/nnweaver/index.html) or build your own offline copy executing `python3 setup.py docs`.
## License ##
This project is licensed under the terms of the MIT License.
Metadata
Release files for nnweaver 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nnweaver-0.2.tar.gz | 15.5 kB | Without provenance | Details for nnweaver-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nnweaver-0.2-py3-none-any.whl | Python 3 | none | any | Details for nnweaver-0.2-py3-none-any.whl |
Total release size: 34.0 kB
Release files / nnweaver-0.2.tar.gz
| Download URL | nnweaver-0.2.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
770ae4efbd369731e10aaa0589e1d922757de37aa180c9d11a53914a2a7c7f5c
|
|
BLAKE2b-256 checksum How to use checksums |
7c11446600dc15f2f73923dad17da4d91460e4d1b8cfb095f645a89478edfacc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.3
|
Release files / nnweaver-0.2-py3-none-any.whl
| Download URL | nnweaver-0.2-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ac0070cb66e30f3e7798be15897c82685d93b533ea4f46ea957f73afe6c8098
|
|
BLAKE2b-256 checksum How to use checksums |
5ffe8753ebabfc20ac862ffc6089569516c86cb5f8c3fc90a351ff89ad02c368
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.3
|
Security for nnweaver 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.