It's really challenging!!!
I'm just feeling that: When neural network goes deep into code, you have to go back to mathematics.
Implement a neural network framework from scratch, and train with 2 examples:
- MNIST Classifier
- Time Series Prediction
- Back Propagation Algorithm
- Model: Sequential(seq)
- Layers: dense(fc), conv2d, flatten, maxpooling2d, dropout
- Activations: relu, sigmoid, softmax
- Optimizor & Training
- Initial learning rate 0.001, set to 5e-5 after loss < 1.0
- SGD(with momentum)
- Gradients Clipping
- l2 Regularization
- Input:(None, 28, 28, 1)
- Conv2D(relu)
- Flatten
- Dropout(0.5)
- Full-Connect(softmax)
85% accuracy after 25w samples with a simple network above.
Actually I had achieved 90% accuracy, but somehow I lost it. It's obviously that, complex model with high accuracy and low loss is harder to train, especially in Python.
- Ubuntu 16.04.2 LTS
- Python 2.7.12(Python 3.6 Also works)
- train MNIST
python train_mnist.py
- test MNIST
python test_mnist.py --weight ./weights/weights-252160-0.797545-0.8575
- inference hand written digits
python inference_mnist.py --dir ./datasets/pics --weight ./weights/weights-252160-0.797545-0.8575
Training dataset goes like this:
X y
1 0 0 ... 0 1 0
0 0 0 ... 0 0 1
0 0 0 ... 0 0 1
1 0 0 ... 0 1 0
1 0 0 ... 0 1 0
Pattern is obviously, right?
- Input:(None, TIME_STEPS, INPUT_DIM)
- RNN(RNN_UNITS)
- Full-Connect(2, with softmax)
python train_rnn.py