Feeding None as hidden state to LSTM/GRU

Hello everybody,

I just came across a behavior that I would expect to throw an exception.
If you feed None as hidden state to nn.GRU or nn.LSTM, it won’t throw an exception.
Instead it will use a hidden state made of zeros.

I’m wondering whether this behavior is intentionally or not.

torch version 1.8.1+cu111

This is intentional.
If you look at the source code you will see :