/NeuralNet

Implementation of a Feed Forward Neural Networks.

Primary LanguagePythonMIT LicenseMIT

NeuralNet

Table of Contents

  1. Introduction
  2. Download
  3. Quick Start
  4. Features
  5. Project Report

Introduction

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.

Download

You can view the source code for the NeuralNet class implementation from this page.

pip install NNeuralNet

Quick Start

Training

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)

Prediction

nn.predict( X_test, returnclass = 1)
# Set returnclass = 0 for class probabilities

Saving a Model

nn.save_model( "my_model.bin")

Loading a Saved Model

nn = NeuralNet.load_model( "my_model.bin")

Features

The NeuralNet class has support for the following features/parameters support: