Repository navigation
Replies: 1 comment
|
There are two independent differences in the manual implementation. First, Keras' LSTM gate order is input, forget, candidate/cell, output ( z_i, z_f, z_c, z_o = np.split(z, 4, axis=1)
i = sigmoid(z_i)
f = sigmoid(z_f)
candidate = np.tanh(z_c)
o = sigmoid(z_o)
c_next = f * c_prev + i * candidate
h_next = o * np.tanh(c_next)Second, the second LSTM receives the entire sequence returned by the first LSTM. Even though its own h2 = np.zeros((1, 8))
c2 = np.zeros((1, 8))
for t in range(window_size):
h2, c2 = lstm_step(
outputs1[:, t, :], h2, c2,
lstm2_weights, lstm2_recurrent_weights, lstm2_bias,
)Dropout is inactive during |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Consider the time series problem with datasets x_train, x_test of dimension (n_steps, window_size, n_features) and y_train, y_test of dimension (n_steps, 1). I have fitted an LSTM model using the following code:
I am trying to exactly replicate the keras model.predict() architecture in order to produce the same prediction for one given time-series step:
However, I am obtaining differences in the output for each layer/step and I am not getting what am I doing wrong. Maybe I am wrongly assigning the fitted weights/biases. Any help? :)
All reactions