How to set number of LSTM blocks in a hidden layer?

Hi I am new to Pytorch.

In Keras,
model = Sequential()
model.add(LSTM(4, input_shape=(1, look_back)))
model.compile(loss=‘mean_squared_error’, optimizer=‘adam’), trainY, epochs=100, batch_size=1, verbose=2)

4 means a hidden layer with 4 LSTM blocks.

How to set this parameter in Pytorch?
Is it the hidden size? (“hidden_size – The number of features in the hidden state h”)


Yup it’s the hidden size

Thank you very much.
I understand more about LSTM.