Skip to content

Brax

Import this adapter from its module, gymnax.wrappers.brax. It requires brax.

GymnaxToBraxWrapper

GymnaxToBraxWrapper(env: Environment)

Bases: Env

Wrap a Gymnax environment as a Brax environment.

Observation, reward and done flag become part of the Brax State, and the PRNG key and environment parameters are carried in state.info. Compatible with all Brax wrappers; AutoResetWrapper is redundant because Gymnax environments already reset automatically. Importing this module requires brax.

Parameters:

action_size property

action_size: int

Size of an action under the default parameters.

observation_size property

observation_size: int | dict[str, tuple[int, ...]]

Observation dimensions under the default parameters, as in Brax.

backend property

backend: str

Name of the backend, always "jax".

reset

reset(key: Array, params: EnvParams | None = None)

Reset the environment and return a Brax State.

The key and parameters are stored in state.info for use by step.

step

step(state, action, params=None)

Advance a Brax State by one step.

Uses the key stored in state.info. If params is given it replaces the stored parameters.