Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import numpy as np
  2. from keras.models import Sequential
  3. from keras.layers import Dense
  4. from keras.layers import LSTM
  5. from keras.layers import Activation
  6. from keras.layers import Masking
  7. from keras.optimizers import RMSprop
  8. from keras import backend as k
  9.  
  10. # Initialize model
  11. model = Sequential()
  12.  
  13. # Mask lookback period to fix sequences of varying lengths
  14. model.add(Masking(mask_value=0., input_shape=(max_time, 24)))
  15.  
  16. # LSTM
  17. model.add(LSTM(50, input_dim=10, return_sequences=True))
  18.  
  19. # Output
  20. model.add(Dense(1))
  21.  
  22. #Exponential activation function (coded separately)
  23. model.add(Activation(expactive))
  24.  
  25.  
  26. model.compile(loss=custom_loss, optimizer=RMSprop(lr=.001))
  27.  
  28. def custom_loss(y,h_out,name=None):
  29. return k.mean(k.pow(h_out - y,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement