-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNN_1B.py
26 lines (17 loc) · 878 Bytes
/
RNN_1B.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from keras.models import Sequential
from keras.layers import Dense, Activation, SimpleRNN
from keras.utils.vis_utils import plot_model
import os
import numpy as np
from reader import Reader
length = Reader.getInputShape()
model = Sequential()
#EXPECTS INPUT AS (nb_sample, timesteps, nb_features), where nb_sample=1 (batch_size = 1), timesteps = 1 and nb_features = length
#model.add(Dense(40, input_dim = 12, init='uniform', activation='relu'))
model.add(SimpleRNN(units=50, input_shape=(1,length), batch_input_shape=(1,1,length), recurrent_initializer='uniform', kernel_initializer='uniform', activation='relu', stateful=True))
model.add(Dense(3, kernel_initializer='uniform', activation = 'softmax'))
model.summary()
plot_model(model, to_file='./RNNmodels/RNN_1B.png', show_shapes=True)
fp = open('./RNNmodels/RNN_1B.json', 'w')
fp.write(model.to_json())
fp.close()