I have asked this question on stackoverflow but nobody answers. So I come here in the hope that somebody could help me solve it. Thank you! Here is my question:
I am a little bit confusing about how should I set parameters in my Keras LSTM model. The dataset is like this:
print(x_train.shape, y_train.shape)
(1000, 626) (1000, 225) #This is a multilabel dataset. Each label has two possibilities either 0 or 1.
I checked Keras document, it says like this:
hidden_units, time steps, input dimension
So should I set it as:
model.add(LSTM(40, activation='relu', input_shape=(626, 1)))
or
model.add(LSTM(40, activation='relu', input_shape=(1,626)))
Note, the hidden units is calculated=40, but then it's smaller than both input and output dimensions. See the following tables:
Tabel one: set input as hidden_units=40, input_shape=(1,626)
Model: "sequential_1"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
LSTM_1 (LSTM) (None, 1, 40) 106720
_________________________________________________________________
LSTM_2 (LSTM) (None, 1, 20) 4880
_________________________________________________________________
Dense_1 (Dense) (None, 1, 250) 5250
_________________________________________________________________
Dense_2 (Dense) (None, 1, 225) 51706
=================================================================
Total params: 168,556
Trainable params: 168,556
Non-trainable params: 0
_________________________________________________________________
Tabel two: Set hidden_units=40, input_shape=(626,1)
Model: "sequential_2"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
LSTM_1 (LSTM) (None, 626, 40) 6720
_________________________________________________________________
LSTM_2 (LSTM) (None, 626, 20) 4880
_________________________________________________________________
Dense_1 (Dense) (None, 626, 250) 5250
_________________________________________________________________
Dense_2 (Dense) (None, 626, 225) 56475
=================================================================
Total params: 73,325
Trainable params: 73,325
Non-trainable params: 0
_________________________________________________________________
In both bases, the output is set based on the dimension of output shape. I 've seen on stackoverflow people have different answers. e.g. this and this
So in this case what is the right way to set those parameters (hidden_units, input_shapes) and output_shapes
Thanks of your help!