set_recurrent_mode¶
- class torchrl.modules.set_recurrent_mode(mode: Optional[Union[bool, Literal['recurrent', 'sequential']]] = True)[source]¶
Context manager for setting RNNs recurrent mode.
- Parameters:
mode (bool, "recurrent" or "sequential") – the recurrent mode to be used within the context manager. “recurrent” leads to mode=True and “sequential” leads to mode=False. An RNN executed with recurrent_mode “on” assumes that the data comes in time batches, otherwise it is assumed that each data element in a tensordict is independent of the others. The default value of this context manager is
True
. The default recurrent mode isNone
, i.e., the default recurrent mode of the RNN is used (seeLSTMModule
andGRUModule
constructors).
See also
recurrent_mode`
.Note
All of TorchRL methods are decorated with
set_recurrent_mode(True)
by default.