Created
January 20, 2019 18:02
-
-
Save fgadaleta/6d1ef988b8c75a04758b57fee61d031c to your computer and use it in GitHub Desktop.
lstm_with_dropout
This file contains hidden or 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
def lstm_net_with_dropout(input_shape, output_dim, dropout=0.15): | |
inputs = keras.Input(shape=input_shape) | |
x = keras.layers.LSTM(30, recurrent_dropout=dropout, return_sequences=True)(inputs, training=True) | |
x = keras.layers.Dropout(dropout)(x, training=True) | |
x = keras.layers.LSTM(30)(x, training=True) | |
x = keras.layers.Dropout(dropout)(x, training=True) | |
outputs = keras.layers.Dense(output_dim)(x) | |
model = keras.Model(inputs, outputs) | |
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['mae', 'mse']) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment