Skip to content

Implementing Multi Layered Perceptron from scratch in python

Notifications You must be signed in to change notification settings

chirag4798/Multi-Layered-Perceptron

Repository files navigation

MultiLayeredPerceptron

Neural Network / Multi Layered Perceptron implemeted from scratch using just vector and matrix computations. The goal of the projects was to understand the intricacies of Deep Neural Network training, gradient flow during backpropagation of loss and experimenting with various optimization methods for faster convergence.

MNIST Dataset

The MNIST database of handwritten digits, it has a training set of 60,000 examples, and a test set of 10,000 examples. It is a subset of a larger set available from NIST. The digits have been size-normalized and centered in a fixed-size image.

It is a good database for people who want to try learning techniques and pattern recognition methods on real-world data while spending minimal efforts on preprocessing and formatting.

The original black and white (bilevel) images from NIST were size normalized to fit in a 20x20 pixel box while preserving their aspect ratio. The resulting images contain grey levels as a result of the anti-aliasing technique used by the normalization algorithm. the images were centered in a 28x28 image by computing the center of mass of the pixels, and translating the image so as to position this point at the center of the 28x28 field.

Source

Sample Image from the dataset

Network Architecture

# Model Architecture
inputs = 784
layers = [32, 16]
output = 10
mlp = MultiLayeredPerceptron(n_inputs=inputs, hidden_layers=layers, n_outputs=output, activation_function='sigmoid')

Training

mlp.GradientDescent(X_train, Y_train, learning_rate=0.01, epochs=100,  beta1=0.9, beta2=0.999)
mlp.plot_loss()

Evaluation

y_pred_train_classes = mlp.predict(X_train.values)
y_pred_test_classes = mlp.predict(X_test.values)

About

Implementing Multi Layered Perceptron from scratch in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published