Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- regressor = Sequential()
- regressor.add(LSTM(units=32, return_sequences=True, input_shape=(X_train.shape[1],1)))
- regressor.add(LSTM(units=32,return_sequences=False))
- regressor.add(Dense(units=1))
- Layer (type) Output Shape Param #
- =================================================================
- lstm_3 (LSTM) (None, 60, 32) 4352
- _________________________________________________________________
- lstm_4 (LSTM) (None, 32) 8320
- _________________________________________________________________
- dense_2 (Dense) (None, 1) 33
- =================================================================
- Total params: 12,705
- Trainable params: 12,705
- Non-trainable params: 0
- for i in range(240)
- 1. Select the last 60 values (my timestep)
- 2. Use sequence generated in step 1 to predict the new value.
- 3. Remove [0] item on my sequence generated in step 1, and push the value that I generated in step 2 to my sequence.
- sequence_timestep = 60
- last_sequence_train = X_train[-1]
- predictions = []
- def sequence_constructor():
- if len(predictions) >= sequence_timestep:
- new_sequence = predictions[-dimension_seq:]
- else:
- splitter = sequence_timestep - len(predictions)
- part_1 = last_sequence_train[-splitter:]
- new_sequence = np.append(part_1,predictions) #Concatenate 2 list
- new_sequence = np.array(new_sequence)
- return new_sequence
- for i in range(240):
- new_sequence = sequence_constructor()
- new_prediction = model.predict(new_sequence)
- predictions.append(new_prediction)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement