Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from keras.models import Sequential
- from keras.layers import Dense
- from keras.layers import LSTM
- from keras.layers import Activation
- from keras.layers import Masking
- from keras.optimizers import RMSprop
- from keras import backend as k
- # Initialize model
- model = Sequential()
- # Mask lookback period to fix sequences of varying lengths
- model.add(Masking(mask_value=0., input_shape=(max_time, 24)))
- # LSTM
- model.add(LSTM(50, input_dim=10, return_sequences=True))
- # Output
- model.add(Dense(1))
- #Exponential activation function (coded separately)
- model.add(Activation(expactive))
- model.compile(loss=custom_loss, optimizer=RMSprop(lr=.001))
- def custom_loss(y,h_out,name=None):
- return k.mean(k.pow(h_out - y,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement