|
23 | 23 | Optimizer is replaced with RMSprop which yields more stable and steady |
24 | 24 | improvement. |
25 | 25 |
|
26 | | - Reaches 0.93 train/test accuracy after 900 epochs (which roughly corresponds |
27 | | - to 1687500 steps in the original paper.) |
| 26 | + Reaches 0.93 train/test accuracy after 900 epochs |
| 27 | + (which roughly corresponds to 1687500 steps in the original paper.) |
28 | 28 | ''' |
29 | 29 |
|
30 | 30 | batch_size = 32 |
|
34 | 34 |
|
35 | 35 | learning_rate = 1e-6 |
36 | 36 | clip_norm = 1.0 |
37 | | -BPTT_truncate = 28*28 |
38 | 37 |
|
39 | 38 | # the data, shuffled and split between train and test sets |
40 | 39 | (X_train, y_train), (X_test, y_test) = mnist.load_data() |
|
58 | 57 | model.add(SimpleRNN(output_dim=hidden_units, |
59 | 58 | init=lambda shape: normal(shape, scale=0.001), |
60 | 59 | inner_init=lambda shape: identity(shape, scale=1.0), |
61 | | - activation='relu', truncate_gradient=BPTT_truncate, |
62 | | - input_shape=(None, 1))) |
| 60 | + activation='relu', input_shape=X_train.shape[1:])) |
63 | 61 | model.add(Dense(nb_classes)) |
64 | 62 | model.add(Activation('softmax')) |
65 | 63 | rmsprop = RMSprop(lr=learning_rate) |
|
74 | 72 |
|
75 | 73 | print('Compare to LSTM...') |
76 | 74 | model = Sequential() |
77 | | -model.add(LSTM(hidden_units, input_shape=(None, 1))) |
| 75 | +model.add(LSTM(hidden_units, input_shape=X_train.shape[1:])) |
78 | 76 | model.add(Dense(nb_classes)) |
79 | 77 | model.add(Activation('softmax')) |
80 | 78 | rmsprop = RMSprop(lr=learning_rate) |
|
0 commit comments