Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. seq_len = 1000
  2. x_train = np.zeros((1, seq_len, 1)) # [batch_size, seq_len, num_feat]
  3. target = np.linspace(100, 0, num=seq_len).reshape(1, -1, 1)
  4.  
  5. from keras.models import Model
  6. from keras.layers import LSTM, Dense, Input, TimeDistributed
  7.  
  8. x_in = Input((seq_len, 1))
  9. seq1 = LSTM(8, return_sequences=True)(x_in)
  10. dense1 = TimeDistributed(Dense(8))(seq1)
  11. seq2 = LSTM(8, return_sequences=True)(dense1)
  12. dense2 = TimeDistributed(Dense(8))(seq2)
  13. out = TimeDistributed(Dense(1))(dense2)
  14.  
  15. model = Model(inputs=x_in, outputs=out)
  16. model.compile(optimizer='adam', loss='mean_squared_error')
  17.  
  18. history = model.fit(x_train, target, batch_size=1, epochs=1000,
  19. validation_split=0.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement