ray.rllib.algorithms.algorithm_config.AlgorithmConfig.get_rl_module_spec#
- AlgorithmConfig.get_rl_module_spec(env: Any | gymnasium.Env | None = None, spaces: Dict[str, gymnasium.Space] | None = None, inference_only: bool | None = None) RLModuleSpec [source]#
Returns the RLModuleSpec based on the given env/spaces.
- Parameters:
env – An optional environment instance, from which to infer the observation- and action spaces for the RLModule. If not provided, will try to infer from
spaces
, otherwise fromself.observation_space
andself.action_space
. If no information on spaces can be inferred, will raise an error.spaces – Optional dict mapping ModuleIDs to 2-tuples of observation- and action space that should be used for the respective RLModule. These spaces are usually provided by an already instantiated remote EnvRunner (call
EnvRunner.get_spaces()
). If not provided, will try to infer fromenv
, otherwise fromself.observation_space
andself.action_space
. If no information on spaces can be inferred, will raise an error.inference_only – If
True
, the returned module spec will be used in an inference-only setting (sampling) and the RLModule can thus be built in its light version (if available). For example, theinference_only
version of an RLModule might only contain the networks required for computing actions, but misses additional target- or critic networks.
- Returns:
A new RLModuleSpec instance that can be used to build an RLModule.