torch.nn.RNN input

According to the documentation, class torch.nn.RNN takes two inputs, input, h_0. However, I found that even if I only feed input, RNN still returns output, h_n, any idea why?

@ZeweiChu because if hidden states are None , they are initialized as zero tensors, then they are used for computation of next hidden states and RNN outputs new hidden states. You can look at source code and check it :slight_smile:

1 Like