Shortcuts

OnlineDTActor

class torchrl.modules.OnlineDTActor(state_dim: int, action_dim: int, transformer_config: Dict | DecisionTransformer.DTConfig = None, device: DEVICE_TYPING | None = None)[source]

Online Decision Transformer Actor class.

Actor class for the Online Decision Transformer to sample actions from gaussian distribution as presented inresented in “Online Decision Transformer”.

Returns the mean and standard deviation for the gaussian distribution to sample actions from.

Parameters:

Examples

>>> model = OnlineDTActor(state_dim=4, action_dim=2,
...     transformer_config=OnlineDTActor.default_config())
>>> observation = torch.randn(32, 10, 4)
>>> action = torch.randn(32, 10, 2)
>>> return_to_go = torch.randn(32, 10, 1)
>>> mu, std = model(observation, action, return_to_go)
>>> mu.shape
torch.Size([32, 10, 2])
>>> std.shape
torch.Size([32, 10, 2])
classmethod default_config()[source]

Default configuration for OnlineDTActor.

forward(observation: Tensor, action: Tensor, return_to_go: Tensor) Tuple[Tensor, Tensor][source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

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