jaxdem.rl.models.mingru#

Implementation of reinforcement learning models based on MinGRU.

Classes

MinGRUActorCritic(*args, **kwargs)

A recurrent actor-critic with an MLP encoder and a MinGRU torso.

class jaxdem.rl.models.mingru.MinGRUActorCritic(*args: Any, **kwargs: Any)[source]#

Bases: Model

A recurrent actor-critic with an MLP encoder and a MinGRU torso.

This model uses the MinGRU architecture (https://arxiv.org/abs/2410.01201) and relies on a parallel associative scan for sequence-mode training, enabling extremely fast execution.

Parameters:
  • observation_space_size (int) – Flattened observation size (obs_dim).

  • action_space_size (int) – Number of action dimensions (for continuous) or number of discrete actions.

  • key (nnx.Rngs) – Random number generator(s) for parameter initialization.

  • hidden_features (int) – Width of the encoder output.

  • gru_features (int) – MinGRU hidden size. Also the feature size consumed by the policy and value heads.

  • num_layers (int) – Number of MinGRU layers.

  • activation (Callable) – Activation function applied inside the encoder.

  • action_space (distrax.Bijector | ActionSpace | None) – Bijector to constrain the policy probability distribution (continuous only).

  • remat (bool) – Accepted for compatibility but unused since associative scan is memory efficient.

  • actor_sigma_head (bool) – If True, the standard deviation is produced by a learned head on the MinGRU output; otherwise an independent log-std parameter is used. Only used for continuous actions.

  • carry_leading_shape (tuple[int, ...]) – Leading dimensions for the persistent carry tensor h.

  • discrete (bool) – If True, use a categorical distribution for discrete actions.

property observation_space_size: int[source]#
property carry_leading_shape: tuple[int, ...][source]#
reset(shape: tuple[int, ...], mask: Array | None = None) None[source]#

Reset the persistent LSTM carry.

Parameters:
  • shape (tuple[int, ...]) – Leading dims for the carry, e.g. (num_envs, num_agents).

  • mask (optional bool array) – True where to reset entries. Shape (num_envs)

property carry: Any[source]#