hidden_size represents the output size of the last recurrent layer. I guess it’s called hidden_size as the output of the last recurrent layer is usually further transformed (as in the Elman model referenced in the docs). Also, if there are several layers in the RNN module, all the hidden ones will have the same number of features: hidden_size.


num_directions is either 1 or 2 depending on the boolean argument bidirectional. If the sequence is processed in both directions you’ll get two values for each time step.


If you need a fixed number of output features you either set hidden_size to that value, or you add an output layer that maps from hidden_size to your output space.