This repository contains an implementation of a Feed Forward Neural Network from scratch using numpy libraries. We have achieved a testing accuracy of 97.45% on MNIST Dataset and a 88.80.% testing accuracy on Fashion-MNIST Dataset.
You can also find a GPU version of the class NeuralNet in ctrain.py (Uses cupy instead of numpy(CuDa compatible)). We have found about 50~100 x speed boost in training time. We will release the cupy version module soon.
You can view the source code for the NeuralNet class implementation from this page.
pip install NNeuralNet
from NNeuralNet.NeuralNet import NeuralNet
from keras.datasets import mnist
# Import and Preprocess Data
( X_train, Y_train), ( X_test, Y_test) = mnist.load_data()
X_train = X_train.reshape(X_train.shape[0],-1).T
X_test = X_test.reshape(X_test.shape[0],-1).T
nn = NeuralNet( input_size = 784, output_size = 10)
nn.addlayer(128)
nn.addlayer(64)
nn.train( X_train, Y_train, numepochs = 10, learning_rate = 0.001)
nn.predict( X_test, returnclass = 1)
# Set returnclass = 0 for class probabilities
nn.save_model( "my_model.bin")
nn = NeuralNet.load_model( "my_model.bin")
The NeuralNet class has support for the following features/parameters support: