I fitted a tensorflow.keras.layers.LSTM
model and extracted the model weights via get_weights()
. However, I find it hard to interpret the weights array.
To be specific, I set the model by
model = Sequential()
model.add(LSTM(128, input_shape=(10, 10)))
model.add(Dense(1))
and fit the model with the data of the following shape
train_X.shape, train_y.shape, test_X.shape, test_y.shape
## ((23, 10, 10), (23,), (6, 10, 10), (6,))
The code for model fitting:
model.fit(train_X, train_y, epochs=50, batch_size=4,
validation_data=(test_X, test_y), verbose=2, shuffle=True)
The shape of model weights:
[w.shape for w in model.get_weights()]
## [(10, 512), (128, 512), (512,), (128, 1), (1,)]
As you can see from the formula, there are eight weight matrices and four bias vectors. However, I don't know how to match them to the weights array.