RLModuleSpec#
- class ray.rllib.core.rl_module.rl_module.RLModuleSpec(module_class: Type[RLModule] | None = None, observation_space: gymnasium.Space | None = None, action_space: gymnasium.Space | None = None, inference_only: bool = False, learner_only: bool = False, model_config: Dict[str, Any] | DefaultModelConfig | None = None, catalog_class: Type[Catalog] | None = None, load_state_path: str | None = None, model_config_dict: dict | int | None = None)[source]#
Bases:
objectUtility spec class to make constructing RLModules (in single-agent case) easier.
- Parameters:
module_class (Type[RLModule] | None) – The RLModule class to use.
observation_space (gymnasium.Space | None) – The observation space of the RLModule. This may differ from the observation space of the environment. For example, a discrete observation space of an environment, would usually correspond to a one-hot encoded observation space of the RLModule because of preprocessing.
action_space (gymnasium.Space | None) – The action space of the RLModule.
inference_only (bool) – Whether the RLModule should be configured in its inference-only state, in which those components not needed for action computing (for example a value function or a target network) might be missing. Note that
inference_only=TrueANDlearner_only=Trueis not allowed.learner_only (bool) – Whether this RLModule should only be built on Learner workers, but NOT on EnvRunners. Useful for RLModules inside a MultiRLModule that are only used for training, for example a shared value function in a multi-agent setup or a world model in a curiosity-learning setup. Note that
inference_only=TrueANDlearner_only=Trueis not allowed.model_config (Dict[str, Any] | DefaultModelConfig | None) – The model config dict or default RLlib dataclass to use.
catalog_class (Type[Catalog] | None) – The Catalog class to use.
load_state_path (str | None) – The path to the RLModule state to load from. Deprecated. This field will be removed in the future Ray release. To restore RLModule state use
Algorithm.restore_from_path(path=..., component=...)instead. See docs for more details: : https://docs.ray.io/en/latest/rllib/rl-modules.html#checkpointing-rlmodules
PublicAPI (beta): This API is in beta and may change before becoming stable.
Methods
Returns a MultiRLModuleSpec (
selfunder DEFAULT_MODULE_ID key).Builds the RLModule from this spec.
Returns a single agent RLModule spec from a serialized representation.
Returns a serialized representation of the spec.
Updates this spec with the given other spec.
Attributes