Guest User

Untitled

a guest
Jun 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. ...
  2. from keras.models import Sequential
  3. from keras.layers import Dense
  4. from keras.wrappers.scikit_learn import KerasClassifier
  5. from keras.utils import np_utils
  6. ...
  7.  
  8. dim = 10
  9. time = 20
  10. batch_size = 20
  11.  
  12. def baseline_model():
  13. model = Sequential()
  14. model.add(LSTM(12, stateful=True, batch_input_shape=(batch_size, time, dim)))
  15. model.add(Dense(3, activation='softmax'))
  16. model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
  17. return model
  18.  
  19. model = KerasClassifier(build_fn=baseline_model, batch_size=batch_size, shuffle=False)
  20.  
  21. for i in range(100):
  22. model.fit(X_train, y_train, epochs=1)
  23. model.reset_states()
  24.  
  25. for i in range(100):
  26. model.fit(X_train, y_train, epochs=1)
Add Comment
Please, Sign In to add comment