karandesai-96 / digit-classifier
- понедельник, 1 августа 2016 г. в 03:13:31
Python
A single handwritten digit classifier, using the MNIST dataset. Implemented through Artificial Neural Networks in python. A convolutional neural network implmentation in tensorflow is kept in separate branch (this one is under construction).
An implementation of multilayer neural network using Python's numpy
library.
The implementation is a modified version of Michael Nielsen's implementation
in Neural Networks and Deep Learning book.
This book and Stanford's Machine Learning Course by Prof. Andrew Ng are recommended as good resources for beginners. At times, it got confusing to me while referring both resources:
Stanford Course uses MATLAB, which has 1-indexed vectors and matrices.
The book usesnumpy
library of Python, which has 0-indexed vectors and arrays.
Further more, some parameters of a neural network are not defined for the input layer,
hence I didn't get a hang of implementation using Python. For example according to the book,
the bias vector of second layer of neural network was referred as bias[0]
as input
layer(first layer) has no bias vector. So indexing got weird with numpy
and MATLAB.
For total beginners who landed up here before reading anything about Neural Networks:
I have followed a particular convention in indexing quantities. Dimensions of quantities are listed according to this figure.
sizes = [2, 3, 1]
numpy.ndarrays
). weights[l]
is a matrix of weights entering the
lth layer of the network (Denoted as wl).weights[0]
is redundant, and further it
follows as weights[1]
being the collection of weights entering layer 1 and so on.weights = |¯ [[]], [[a, b], [[p], ¯|
| [c, d], [q], |
|_ [e, f]], [r]] _|
numpy.ndarrays
). biases[l]
is a vector of biases of neurons in the
lth layer of network (Denoted as bl).biases[0]
is redundant, and further it
follows as biases[1]
being the biases of neurons of layer 1 and so on.biases = |¯ [[], [[0], [[0]] ¯|
| []], [1], |
|_ [2]], _|
zs[0]
is redundant.zs
will be same as biases
.biases
, zs
and
activations
are similar.activations[0]
can be related
to x - the input trainng example.