Shortcuts

BinarizeReward

class torchrl.envs.transforms.BinarizeReward(in_keys: Sequence[NestedKey] | None = None, out_keys: Sequence[NestedKey] | None = None)[source]

Maps the reward to a binary value (0 or 1) if the reward is null or non-null, respectively.

Parameters:
  • in_keys (List[NestedKey]) – input keys

  • out_keys (List[NestedKey], optional) – output keys. Defaults to value of in_keys.

  • dtype (torch.dtype, optional) – the dtype of the binerized reward. Defaults to torch.int8.

transform_reward_spec(reward_spec: TensorSpec) TensorSpec[source]

Transforms the reward spec such that the resulting spec matches transform mapping.

Parameters:

reward_spec (TensorSpec) – spec before the transform

Returns:

expected spec after the transform

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources