Giter Club home page Giter Club logo

my-own-neural-network's Introduction

My own neural network

My own implementation of a dense neural network successfully trained on MNIST Dataset. We implemented and compared different features for our neural network.

Installation & Usage

OS X & Linux:

sudo apt install virtualenv
virtualenv -p python3 env
source env/bin/activate
pip3 install -r requirements.txt
python3 main.py

Implemented features

  • Layer: Dense
  • Activation function: ReLu
  • Weights initializer: Random Normal, Xavier, Glorot&Bengio, He&Zhang&Ren&Sun
  • Optimizer: SGD, SGD with momentum, Nesterov AGD, RMSProp, AdaGrad, Adam
  • Regularization: L2
  • Drop out: No
  • Batch normalization: No

Dataset used

  • The MNIST DATABASE of handwritten digits

Results

In the following we compare results obtained with different weights initialization methods and different parameters for L2 regularization. We used SGD as optimization method, on 9 epochs with batch size of 32.

Weights Initialization

We compared the following weights initialization methods:

  • random normal distribution (default)
  • Glorot&Bengio initialization
  • Xavier initialization
  • He&Zhang&Ren&Sun initialization

Conclusion:

  • We observe that Xavier, Glorot&Bengio and He&Zhang&Ren&Sun methods worked better than the default initialization since with the 3 methods we had convergence at the first epoch while it took 7 epochs to converge with the default initialization.

These methods indeed help to preserve the variance of the flow through the network, preventing early vanishing or exploding gradients.

  • He&Zhang&Ren&Sun gave us the better initialization which was expected since this method is the adapted version of Xavier initialization for non linear activations producing sparsity like ReLu function which we used.

L2 Regularization

We compared the following L2 regularization parameters:

  • 0
  • 0.01
  • 0.005
  • 0.0007

Conclusion:

  • We obsverve that WITH a regularization term the gap between train and val accuracy is lower (<0.7%) than WITHOUT a regularization term (1.6%). Therefore the introduction of a regularization reduces overfitting.

  • We could achieve a better validation accuracy with a regularization term of 0.0007 (97.67%) than without (97.5%).

my-own-neural-network's People

Contributors

salimandre avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.