快捷方式

register_gym_spec_conversion

torchrl.envs.register_gym_spec_conversion(spec_type)[来源]

为特定的 spec 类型注册转换函数。 (Decorator to register a conversion function for a specific spec type.)

该方法必须具有以下签名 (The method must have the following signature)

>>> @register_gym_spec_conversion("spec.name")
... def convert_specname(
...     spec,
...     dtype=None,
...     device=None,
...     categorical_action_encoding=None,
...     remap_state_to_observation=None,
...     batch_size=None,
... ):

其中 gym(nasium).spaces.spec.name 是 spec 在 gym 中的位置。 (where gym(nasium).spaces.spec.name is the location of the spec in gym.)

如果 spec 类型可访问,这将同样有效 (If the spec type is accessible, this will also work)

>>> @register_gym_spec_conversion(SpecType)
... def convert_specname(
...     spec,
...     dtype=None,
...     device=None,
...     categorical_action_encoding=None,
...     remap_state_to_observation=None,
...     batch_size=None,
... ):

..note:: 被包装的函数可以被简化,未使用的关键字参数可以用 **kwargs 包装。 (..note:: The wrapped function can be simplified, and unused kwargs can be wrapped in **kwargs.)

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

查找开发资源并让您的问题得到解答

查看资源