Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from keras.models import Sequential, load_model
- from keras.layers import Bidirectional, Dropout, Dense, LSTM
- import numpy as np
- import keras
- print(keras.__version__)
- SEGMENT_TIME_SIZE=10
- N_FEATURES=10
- N_CLASSES=10
- N_HIDDEN_NEURONS=10
- model = Sequential()
- model.add(Bidirectional(LSTM(N_HIDDEN_NEURONS,
- return_sequences=True,
- activation="tanh",
- input_shape=(SEGMENT_TIME_SIZE, N_FEATURES))))
- model.add(Bidirectional(LSTM(N_HIDDEN_NEURONS)))
- model.add(Dropout(0.5))
- model.add(Dense(N_CLASSES, activation='sigmoid'))
- model.compile('adam', 'binary_crossentropy', metrics=['accuracy'])
- model.fit(np.random.rand(10, SEGMENT_TIME_SIZE, N_FEATURES), np.random.randn(10, N_CLASSES))
- model.save('model.h5')
- model = load_model('model.h5')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement