- Digit Classification using Two Layer Neural Network and Back Propagation. Written in Python3 and depends only on Numpy.
- Implimentation of:
- Artificial Neural Network. (Notebooks/ANN.ipynb)
- Convolutional Neural Network. (Notebooks/CNN.ipynb)
- Recurrent Neural Network. (Notebooks/RNN.ipynb)
- Download the data in csv format from here :- https://pjreddie.com/projects/mnist-in-csv/.
- Already downloaded and kept the MNIST test data in the ./data/ folder. Training data size was large for Github.
- Python script, dataloader.py helps in converting the data from csv to numpy format.
- Verify your above steps are correct by running the script
- The script requires two user inputs
i) datapath = path to the data folder inside which the MNIST CSVs files are stored.
ii) mode = 'train' or 'test' to extract the training or test data
iii) For example :-
```
-
Python Script , neural_net.py contains all the APIs used for training the model, saving the model and running over the test data
-
The script requires three user inputs
i) mode = 'train' or 'test'
ii) datapath = path to the data folder inside which the MNIST CSVs files are stored.
iii) modelpath = path to store the trained weight or load the weights during the test timeiv) Example:-
```python3 neural_net.py train ./data ./new_model ```
-
I have already provided the trained model inside the model folder and the test data inside the data folder.
-
To get started, use the follwing command.
If everything is set-up well, you should see the following results on your console.
Loading Dataset===>
Done!
Loading Trained Weights......
Testing Iteration===>0, Acc ====>0.9766
Testing Iteration===>1, Acc ====>0.9609
Testing Iteration===>2, Acc ====>0.9844
-- -- -- -- -- -- --
-- -- -- -- -- -- --
Testing Iteration===>76, Acc ====>0.9297
Testing Iteration===>77, Acc ====>0.9687
- I have kept some images from MNIST inside the images folder.
- To use this code, install opencv to read the image.
- Run using :-
python3 run_on_image.py images/img_4.png ./model_bn/
- Number of Hidden Layers - 2
- Hidden Layer Sizes - (1024, 2048)
- Learning Rate - 0.001
- Batch Size - 128
- Number of epoch for training - 1000000
- Batch Norm Decay Rate - 0.9
- Faster Convergence and better accuracy by using Batch Normalization before Relu operation. Please refere to the plots below.
- Experiments with increasing the hidden layers and size might help us in finding a sweet spot where we are neither underfitting nor overfitting.