Skip to content

Instantly share code, notes, and snippets.

@Eligijus112
Created February 11, 2020 06:22
Show Gist options
  • Save Eligijus112/750d1ff3e98fa59c9f341030b814188e to your computer and use it in GitHub Desktop.
Save Eligijus112/750d1ff3e98fa59c9f341030b814188e to your computer and use it in GitHub Desktop.
An LSTM neural network for time series
# Deep learning packages
from keras.models import Sequential
from keras.layers import LSTM, Dense
# Defining the number of neurons in the LSTM layer
n_layer = 50
# Defining how many lags will be used in the time series
n_lag = 3
# Defining the model
model = Sequential()
model.add(LSTM(n_layer, activation='relu', input_shape=(n_lag, 1)))
model.add(Dense(1))
# The objective functions which will be minimized is mean squared error (mse)
model.compile(optimizer='adam', loss='mse')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment