Digit Recognizer is a library where the algorithm Multilayer Perceptron is implemented with intent to teach a neural network learn how to recognize handwritten numbers based on MNIST dataset. It's important remember, this is a basic implementation where there's NO OPTIMIZATION at algorithm, in other words, the training is SLOW but the results are satisfactory.
The book used as support material is: HAYKIN, Simon. Redes Neurais: Princípios e Prática.
A definition according to MNIST database of handwritten digits:
Is a database of handwritten digits, has a training set of 60,000 examples, and a test set of 10,000 examples. The digits have been size-normalized and centered in a fixed-size image (28 x 28). 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.
$ pip install -r requirements.txt
A brief explanation of each method of this repository.
-
NeuralNetwork.py
- The constructor NeuralNetwork receives as argument the number of epochs and learning rate. e.g.
NeuralNetwork(10, 0.5)
- Add a layer to the network with quantity of neurons passed as argument.
def add(self, num_nodes)
- Receives the values of inputs and outputs of training dataset.
def train(self, inputs, targets)
- Receives a value and return the output of neural network.
def query(self, in_list)
- Receives an test input and output and return the precision of network.
def acc(self, in_list, out_list)
- Receives a name and save the neural network at the working directory.
def save(self, file_name)
- Receives a path of saved neural network and load into memory.
def load(self, path_json)
-
Image.py
- Receives an output of mnist as array and return the corresponding value.
def arrayToNum(array)
- Receives an mninst array and the value generated for the network, then plots the image and print the value.
plotNum(mnist_num, output_value)
-
LoadMNIST.py
- Receives the path of MNIST files and return the arrays of training and testing normalizeds.
def generateData(path)