1212from keras .utils import np_utils
1313
1414'''
15- This is a reproduction of the IRNN experiment
15+ This is a reproduction of the IRNN experiment
1616 with pixel-by-pixel sequential MNIST in
1717 "A Simple Way to Initialize Recurrent Networks of Rectified Linear Units "
1818 by Quoc V. Le, Navdeep Jaitly, Geoffrey E. Hinton
2323 Optimizer is replaced with RMSprop which yields more stable and steady
2424 improvement.
2525
26- 0.80 train/test accuracy and 0.55 train/test loss after 70 epochs
27- (it's still underfitting at that point, though).
26+ Reaches 0.93 train/test accuracy after 900 epochs (which roughly corresponds
27+ to 1687500 steps in the original paper.)
2828'''
2929
3030batch_size = 32
6464rmsprop = RMSprop (lr = learning_rate )
6565model .compile (loss = 'categorical_crossentropy' , optimizer = rmsprop )
6666
67- model .fit (X_train , Y_train , batch_size = 16 , nb_epoch = nb_epochs ,
67+ model .fit (X_train , Y_train , batch_size = batch_size , nb_epoch = nb_epochs ,
6868 show_accuracy = True , verbose = 1 , validation_data = (X_test , Y_test ))
6969
7070scores = model .evaluate (X_test , Y_test , show_accuracy = True , verbose = 0 )
7979rmsprop = RMSprop (lr = learning_rate )
8080model .compile (loss = 'categorical_crossentropy' , optimizer = rmsprop )
8181
82- model .fit (X_train , Y_train , batch_size = 16 , nb_epoch = nb_epochs ,
82+ model .fit (X_train , Y_train , batch_size = batch_size , nb_epoch = nb_epochs ,
8383 show_accuracy = True , verbose = 1 , validation_data = (X_test , Y_test ))
8484
8585scores = model .evaluate (X_test , Y_test , show_accuracy = True , verbose = 0 )
8686print ('LSTM test score:' , scores [0 ])
87- print ('LSTM test accuracy:' , scores [1 ])
87+ print ('LSTM test accuracy:' , scores [1 ])
0 commit comments