Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- seq_len = 1000
- x_train = np.zeros((1, seq_len, 1)) # [batch_size, seq_len, num_feat]
- target = np.linspace(100, 0, num=seq_len).reshape(1, -1, 1)
- from keras.models import Model
- from keras.layers import LSTM, Dense, Input, TimeDistributed
- x_in = Input((seq_len, 1))
- seq1 = LSTM(8, return_sequences=True)(x_in)
- dense1 = TimeDistributed(Dense(8))(seq1)
- seq2 = LSTM(8, return_sequences=True)(dense1)
- dense2 = TimeDistributed(Dense(8))(seq2)
- out = TimeDistributed(Dense(1))(dense2)
- model = Model(inputs=x_in, outputs=out)
- model.compile(optimizer='adam', loss='mean_squared_error')
- history = model.fit(x_train, target, batch_size=1, epochs=1000,
- validation_split=0.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement