Created
April 8, 2020 21:52
-
-
Save codingsnap/939abc30b9fed24914950d910d563b30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Sequential, load_model | |
from keras.layers import * | |
from keras.callbacks import ModelCheckpoint, EarlyStopping | |
model = Sequential() | |
model.add( LSTM(units=512, | |
input_shape = (normalised_network_input.shape[1], normalised_network_input.shape[2]), | |
return_sequences = True) ) | |
model.add( Dropout(0.3) ) | |
model.add( LSTM(512, return_sequences=True) ) | |
model.add( Dropout(0.3) ) | |
model.add( LSTM(512) ) | |
model.add( Dense(256) ) | |
model.add( Dropout(0.3) ) | |
model.add( Dense(n_vocab, activation="softmax") ) | |
model.compile(loss="categorical_crossentropy", optimizer="adam") | |
model.summary() | |
checkpoint = ModelCheckpoint("model.hdf5", monitor='loss', verbose=0, save_best_only=True, mode='min') | |
model_his = model.fit(normalised_network_input, network_output, epochs=100, batch_size=64, callbacks=[checkpoint]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment