Created
February 11, 2020 06:22
-
-
Save Eligijus112/750d1ff3e98fa59c9f341030b814188e to your computer and use it in GitHub Desktop.
An LSTM neural network for time series
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
| # 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