All Projects → integeruser → MNIST-cnn

integeruser / MNIST-cnn

Licence: MIT license
Convolutional neural networks with Python 3

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to MNIST-cnn

amr
Official adversarial mixup resynthesis repository
Stars: ✭ 31 (+63.16%)
Mutual labels:  mnist-dataset
CVAE-AnomalyDetection-PyTorch
Example of Anomaly Detection using Convolutional Variational Auto-Encoder (CVAE)
Stars: ✭ 23 (+21.05%)
Mutual labels:  mnist-dataset
Hand-Digits-Recognition
Recognize your own handwritten digits with Tensorflow, embedded in a PyQT5 GUI. The Neural Network was trained on MNIST.
Stars: ✭ 11 (-42.11%)
Mutual labels:  mnist-dataset
mnist-draw
Draw and classify digits (0-9) in a browser using machine learning
Stars: ✭ 27 (+42.11%)
Mutual labels:  mnist-dataset
MNIST-CoreML
Predict handwritten digits with CoreML
Stars: ✭ 63 (+231.58%)
Mutual labels:  mnist-dataset
xRBM
Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow
Stars: ✭ 51 (+168.42%)
Mutual labels:  mnist-dataset
videoMultiGAN
End to End learning for Video Generation from Text
Stars: ✭ 53 (+178.95%)
Mutual labels:  mnist-dataset
Handwritten-Digits-Classification-Using-KNN-Multiclass Perceptron-SVM
🏆 A Comparative Study on Handwritten Digits Recognition using Classifiers like K-Nearest Neighbours (K-NN), Multiclass Perceptron/Artificial Neural Network (ANN) and Support Vector Machine (SVM) discussing the pros and cons of each algorithm and providing the comparison results in terms of accuracy and efficiecy of each algorithm.
Stars: ✭ 42 (+121.05%)
Mutual labels:  mnist-dataset
MNIST
Handwritten digit recognizer using a feed-forward neural network and the MNIST dataset of 70,000 human-labeled handwritten digits.
Stars: ✭ 28 (+47.37%)
Mutual labels:  mnist-dataset
Deep-Learning-in-R-using-Keras-and-Tensorflow-
Implementing Deep learning in R using Keras and Tensorflow packages for R and implementing a Multi layer perceptron Model on MNIST dataset and doing Digit Recognition
Stars: ✭ 24 (+26.32%)
Mutual labels:  mnist-dataset

MNIST-cnn

This repository contains a Python 3 naïve implementation of a neural network with convolutional and pooling layers, useful for educational purposes. It was tested with satisfactory results the on the well-known MNIST data set.

Alessandro and Francesco

Prerequisites

The code makes heavy use of NumPy. Install it using pip:

~ ➤ pip3 install --user numpy

Then, download the MNIST data set (four .gz archives) and decompress it:

~ ➤ cd Downloads
Downloads ➤ ls
t10k-images-idx3-ubyte.gz  t10k-labels-idx1-ubyte.gz  train-images-idx3-ubyte.gz train-labels-idx1-ubyte.gz
Downloads ➤ gzip -d *
Downloads ➤ ls
t10k-images-idx3-ubyte  t10k-labels-idx1-ubyte  train-images-idx3-ubyte train-labels-idx1-ubyte

Note: on Windows, as per our tests, the extracted files will have a different name of the ones showed above (e.g. train-images.idx3-ubyte instead of train-images-idx3-ubyte). You can either manually rename the extracted files or modify lines 10-13 of src/utils.py.

Usage

Convert the downloaded data set to the NPZ binary data format using the function build_mnist_npz() from src/utils.py:

MNIST-cnn ➤ cd src
src ➤ ls
examples.py  functions.py layers.py    network.py   utils.py
src ➤ python3 -q
>>> import utils
>>> utils.build_mnist_npz('/Users/fcagnin/Downloads')
>>> exit()
src ➤ file mnist.npz
mnist.npz: Zip archive data, at least v2.0 to extract

Finally, run any of the included examples:

src ➤ time python3 -OO examples.py mnist.npz fcl01
Loading 'mnist.npz'...
Loading 'fcl01'...
def fcl01():
    net = n.NeuralNetwork([
        l.InputLayer(height=28, width=28),
        l.FullyConnectedLayer(100, init_func=f.glorot_uniform, act_func=f.sigmoid),
        l.FullyConnectedLayer(10, init_func=f.glorot_uniform, act_func=f.sigmoid)
    ], f.quadratic)
    optimizer = o.SGD(3.0)
    num_epochs = 1
    batch_size = 10
    return net, optimizer, num_epochs, batch_size
Training network...
Epoch 01 [==========] [50000/50000] > Validation accuracy: 95.41%
Testing network...
Test accuracy: 95.07%
python3 -OO examples.py mnist.npz fcl01  24.10s user 4.07s system 130% cpu 21.517 total
src ➤ time python3 examples.py mnist.npz cnn01
Loading 'mnist.npz'...
Loading 'cnn01'...
def cnn01():
    net = n.NeuralNetwork([
        l.InputLayer(height=28, width=28),
        l.ConvolutionalLayer(2, kernel_size=5, init_func=f.glorot_uniform, act_func=f.sigmoid),
        l.MaxPoolingLayer(pool_size=2),
        l.FullyConnectedLayer(height=10, init_func=f.glorot_uniform, act_func=f.softmax)
    ], f.log_likelihood)
    optimizer = o.SGD(0.1)
    num_epochs = 3
    batch_size = 10
    return net, optimizer, num_epochs, batch_size
Training network...
Epoch 01 [==========] [50000/50000] > Validation accuracy: 88.86%
Epoch 02 [==========] [50000/50000] > Validation accuracy: 89.84%
Epoch 03 [==========] [50000/50000] > Validation accuracy: 89.11%
Testing network...
Test accuracy: 88.53%
python3 examples.py mnist.npz cnn01  2869.89s user 11.16s system 99% cpu 45:12.89 total
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].