DTActor¶
- class torchrl.modules.DTActor(state_dim: int, action_dim: int, transformer_config: Dict | DecisionTransformer.DTConfig = None, device: DEVICE_TYPING | None = None)[source]¶
Decision Transformer Actor 類。
Decision Transformer 的 Actor 類,用於輸出確定性動作,如 “Decision Transformer” <https://arxiv.org/abs/2202.05607.pdf> 中所述。返回確定性動作。
- 引數:
state_dim (int) – 狀態維度。
action_dim (int) – 動作維度。
transformer_config (Dict or
DecisionTransformer.DTConfig, optional) – GPT2 transformer 的配置。預設為default_config()。device (torch.device, optional) – 要使用的裝置。預設為 None。
示例
>>> model = DTActor(state_dim=4, action_dim=2, ... transformer_config=DTActor.default_config()) >>> observation = torch.randn(32, 10, 4) >>> action = torch.randn(32, 10, 2) >>> return_to_go = torch.randn(32, 10, 1) >>> output = model(observation, action, return_to_go) >>> output.shape torch.Size([32, 10, 2])