Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. regressor = Sequential()
  2. regressor.add(LSTM(units=32, return_sequences=True, input_shape=(X_train.shape[1],1)))
  3. regressor.add(LSTM(units=32,return_sequences=False))
  4. regressor.add(Dense(units=1))
  5.  
  6.  
  7. Layer (type) Output Shape Param #
  8. =================================================================
  9. lstm_3 (LSTM) (None, 60, 32) 4352
  10. _________________________________________________________________
  11. lstm_4 (LSTM) (None, 32) 8320
  12. _________________________________________________________________
  13. dense_2 (Dense) (None, 1) 33
  14. =================================================================
  15. Total params: 12,705
  16. Trainable params: 12,705
  17. Non-trainable params: 0
  18.  
  19. for i in range(240)
  20. 1. Select the last 60 values (my timestep)
  21. 2. Use sequence generated in step 1 to predict the new value.
  22. 3. Remove [0] item on my sequence generated in step 1, and push the value that I generated in step 2 to my sequence.
  23.  
  24. sequence_timestep = 60
  25. last_sequence_train = X_train[-1]
  26.  
  27. predictions = []
  28.  
  29. def sequence_constructor():
  30. if len(predictions) >= sequence_timestep:
  31. new_sequence = predictions[-dimension_seq:]
  32. else:
  33. splitter = sequence_timestep - len(predictions)
  34. part_1 = last_sequence_train[-splitter:]
  35. new_sequence = np.append(part_1,predictions) #Concatenate 2 list
  36. new_sequence = np.array(new_sequence)
  37. return new_sequence
  38.  
  39. for i in range(240):
  40. new_sequence = sequence_constructor()
  41. new_prediction = model.predict(new_sequence)
  42. predictions.append(new_prediction)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement