What are torch.nn.Parameter's in torch.nn.LSTM?

Hello to everyone!
I am struggling to understand what are torch.nn.Parameter in torch.nn.LSTM?
I have build a toy model and it seems to have 4 torch.nn.Paramater’s.
What are they in the following formulas?
lstm

Andrei

1 Like

Have a look at docs under the Variables paragraph.

Posting it here will mess up the format, but you’ll find some information about which internal LSTM parameters contain which part of the weight and bias matrices:

LSTM.weight_ih_l[k] – the learnable input-hidden weights …

You can access these parameters directly via:

lstm = nn.LSTM(1, 1)
for name, _ in lstm.named_parameters():
    print(name)

> weight_ih_l0
weight_hh_l0
bias_ih_l0
bias_hh_l0

lstm.weight_ih_l0

Thank you @ptrblck it is really helpful. Long life PyTorch.

Andrei

1 Like