A simple package for modelling multidimensional non-linear functions using artificial neural networks
Project description
NNFunction
A simple package for modelling multidimensional non-linear functions using artificial neural networks.
Installation
Install from pip3
:
pip3 install --user NNFunction
Or by cloning this repository:
#clone the repo
git clone https://github.com/mattkjames7/NNFunction
cd NNFunction
#Either create a wheel and use pip: (X.X.X should be replaced with the current version)
python3 setup.py bdist_wheel
pip3 install --user dists/NNFunction-X.X.X-py3-none-any.whl
#Or by using setup.py directly
python3 setup.py install --user
Usage
Start by training training a network:
import NNFunction as nnf
#create the network, defining the activation functions and the number of nodes in each layer
net = nnf.NNFunction(s,AF='softplus',Output='linear')
#note that s should be a list, where each element denotes the number of nodes in each layer
#input training data
net.AddData(X,y)
#Input matrix X should be of the shape (m,n) - where m is the number of samples and n is the number of input features
#Output hypothesis matrix y should have the shape (m,k) - where k is the number of output nodes
#optionally add validation and test data
net.AddValidationData(Xv,yv)
#Note that validation data is ignored if kfolds > 1 during training
net.AddTestData(Xt,yt)
#Train the network
net.Train(nEpoch,kfolds=k)
#nEpoch is the number of training epochs
#kfolds is the number of kfolds to do - if kfolds > 1 then the training data are split
#into kfold sets, each of which has a turn at being the validation set. This results in
#kfold networks being trained in total (net.model)
#see docstring net.Train? to see more options
After training, the cost function may be plotted:
net.PlotCost(k=k)
We can use the network on other data:
#X in this case is a new matrix
y = net.Predict(X)
The networks can be saved and reloaded:
#save
net.Save(fname='networkname.bin')
#reload
net = nnf.LoadANN(fname='networkname.bin')
The animation below demonstrates the training of a neural network used to reproduce four different functions simultaneously. It was produced using NNFunction.TrainNN4
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file NNFunction-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: NNFunction-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7173cacc5a23f5a6065e6e6da5f3db85a585521bd0c3396e0459066877c3d9b9 |
|
MD5 | 42b3ec6c81e2b1feba74f4ac8b501755 |
|
BLAKE2b-256 | 88611588c7096ce09d6bc1042e65ed43a49217974cd97be39f5c00480b6d9386 |