Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shahardekel/mnist-classifier
MNIST Classifier on Python- using only Torch Tensor manipulations
https://github.com/shahardekel/mnist-classifier
Last synced: about 17 hours ago
JSON representation
MNIST Classifier on Python- using only Torch Tensor manipulations
- Host: GitHub
- URL: https://github.com/shahardekel/mnist-classifier
- Owner: shahardekel
- Created: 2020-12-30T09:34:17.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-30T09:48:26.000Z (almost 4 years ago)
- Last Synced: 2023-09-04T14:50:31.811Z (about 1 year ago)
- Language: Python
- Size: 243 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MNIST-Classifier
MNIST Classifier on Python- using only Torch Tensor manipulations.
NOT allowed to use:
○ Auto-differentiation - backward()
○ Built-in loss functions
○ Built-in activations
○ Built-in optimization
○ Built-in layers (torch.nn)Obtained at least 75% accuracy on the test set (got 92%).
Inside the train file is the MNIST training process.
We got an input of 784 (28 pixels * 28 pixels), the training worked best for us with 1 hidden layer in size 64,
batch size of 100, learning rate = 1 and with 50 epochs.We first set up a net with weights and biases (according to the size of the hidden layer).
We started the forward process where we used sigmoid on the hidden layer and softmax on the result.Next, we performed the backward process, using the gradients we calculated in the theoretical part and the predicted
values from the forward phase.
In the backward process we tried to learn with learning rate = 0.001, then with 0.01 and in the end we got
the best result with learning rate = 1.
To know the percentage of accuracy on the net, we performed a loop that goes through each epoch
(at first we tried sizes 10, 30 and in the end we got the best result with a size of 50).
For each epoch we calculated whether we were right in our prediction.In the evaluate file we performed the same process, on the test set.
At the end we printed the average accuracy on the test set and two graphs describing the accuracy
of the sets in relation to the time (the epochs).Hyperparameters:
input_size = 784
hidden_size = 64
num_classes = 10
num_epochs = 50
batch_size = 100
learning_rate = 1Files Description:
1. train.py - The MNIST training process
2. model.pkl - The trained network with trained weights
3. eval.py - A file with a function called "evaluate()". The function load the MNIST test-set, load our trained network, and return the average accuracy over the test-set.