Advertisement
Guest User

broken keras code

a guest
Jul 8th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. from keras.models import Sequential, load_model
  2. from keras.layers import Bidirectional, Dropout, Dense, LSTM
  3. import numpy as np
  4. import keras
  5.  
  6. print(keras.__version__)
  7.  
  8. SEGMENT_TIME_SIZE=10
  9. N_FEATURES=10
  10. N_CLASSES=10
  11. N_HIDDEN_NEURONS=10
  12.  
  13. model = Sequential()
  14. model.add(Bidirectional(LSTM(N_HIDDEN_NEURONS,
  15. return_sequences=True,
  16. activation="tanh",
  17. input_shape=(SEGMENT_TIME_SIZE, N_FEATURES))))
  18. model.add(Bidirectional(LSTM(N_HIDDEN_NEURONS)))
  19. model.add(Dropout(0.5))
  20. model.add(Dense(N_CLASSES, activation='sigmoid'))
  21. model.compile('adam', 'binary_crossentropy', metrics=['accuracy'])
  22.  
  23. model.fit(np.random.rand(10, SEGMENT_TIME_SIZE, N_FEATURES), np.random.randn(10, N_CLASSES))
  24.  
  25.  
  26. model.save('model.h5')
  27. model = load_model('model.h5')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement