Shortcuts

Resize

class torchrl.envs.transforms.Resize(w: int, h: Optional[int] = None, interpolation: str = 'bilinear', in_keys: Optional[Sequence[NestedKey]] = None, out_keys: Optional[Sequence[NestedKey]] = None)[source]

Resizes a pixel observation.

Parameters:
  • w (int) – resulting width.

  • h (int, optional) – resulting height. If not provided, the value of w is taken.

  • interpolation (str) – interpolation method

Examples

>>> from torchrl.envs import GymEnv
>>> t = Resize(64, 84)
>>> base_env = GymEnv("HalfCheetah-v4", from_pixels=True)
>>> env = TransformedEnv(base_env, Compose(ToTensorImage(), t))
transform_observation_spec(observation_spec: TensorSpec) TensorSpec[source]

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

Parameters:

observation_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