class torchrl.modules.RSSMPrior(action_spec, hidden_dim=200, rnn_hidden_dim=200, state_dim=30, scale_lb=0.1)[source]

The prior network of the RSSM.

This network takes as input the previous state and belief and the current action. It returns the next prior state and belief, as well as the parameters of the prior state distribution. State is by construction stochastic and belief is deterministic. In “Dream to control”, these are called “deterministic state ” and “stochastic state”, respectively.


  • action_spec (TensorSpec) – Action spec.

  • hidden_dim (int, optional) – Number of hidden units in the linear network. Input size of the recurrent network. Defaults to 200.

  • rnn_hidden_dim (int, optional) – Number of hidden units in the recurrent network. Also size of the belief. Defaults to 200.

  • state_dim (int, optional) – Size of the state. Defaults to 30.

  • scale_lb (float, optional) – Lower bound of the scale of the state distribution. Defaults to 0.1.

forward(state, belief, action)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.


Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources