A light weight simple, multi layer ,feedforward neural network library
TINN acronym for Tiny Neural Network is a lightweight, neural network library,build over numpy.
You can download tinn using pip via pypi.
$ pip install tinn
Creating a neural network
Lets start by creating a 3 layer neural network
First start with importing the required modules
from tinn.neural import NeuralNet from tinn.layer import Layer
A neural network is composed of a series of layers of neurons, such that all the neurons in each layer connect to the neurons in the next layer.
Lets see how to make a layer using tinn.
A layer in tinn requires 2 parameters
- num_neurons : No of neurons in that layer
- activation : Activation function for that layer
Lets create a layer with 5 neurons and sigmoid activation function
Once the layer is created a neural network can be created by combining multiple layers using
model= NeuralNet() # Creates an empty neural network with 0 layers model.add(Layer(3,'sigmoid') # Hidden layer with 3 neurons model.add(Layer(5,'sigmoid') # Hidden layer with 5 neurons model.add(Layer(1,'sigmoid') # Outpput layer with1 neuron
Above code creates a 3 layered neural network with 2 hidden layers and 1 output layer.
Training the model
tinn.neural.NeuralNet.train() can be used to train the neural network on a given set of training data using stochastic gradient descent algorithm.
Here is the prototype of train method in NeuralNet class.
- inputData : An array of all inputs of the training set.
- outputData : Array of corresponding outputs of the training set.
- learning_rate : Could be used to tweak the learning rate parameter
- epocs : Default epocs is 100, it denotes the number of traning iterations over the given dataset
- suffle : If set to false, dataset will not be shuffled between epocs.
Accuracy of the model
tinn.neural.NeuralNet.validate() is used to compute the accuracy of the model on given testing data. It returns a floating number between [0,1] inclusive where 1 represents 100 percent accuracy.
Once the model is trained
tinn.neural.NeuralNet.predict() can be used to get the predicted outputs from the trained neural network.
Saving the model
tinn.neural.NeuralNet.save() saves the model to a file.
Saves the model along with weights and architecture ,in the specified file, uses pickle module of python.
Loading the model
Trained model can be loaded from the file using
Once loaded the model can be use for prediction.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size tinn-2.1.tar.gz (5.9 kB)||File type Source||Python version None||Upload date||Hashes View|