DdpgMlpActor¶
- class torchrl.modules.DdpgMlpActor(action_dim: int, mlp_net_kwargs: dict | None = None, device: DEVICE_TYPING | None = None)[源代码]¶
DDPG Actor 类。
在“使用深度强化学习进行连续控制”中提出,https://arxiv.org/pdf/1509.02971.pdf
DDPG Actor 将观测向量作为输入,并从中返回一个动作。它经过训练以最大化 DDPG Q 值网络返回的值。
- 参数:
action_dim (int) – 动作向量的长度
mlp_net_kwargs (dict, 可选) –
MLP 的关键字参数。默认为
>>> { ... 'in_features': None, ... 'out_features': action_dim, ... 'depth': 2, ... 'num_cells': [400, 300], ... 'activation_class': nn.ELU, ... 'bias_last_layer': True, ... }
device (torch.device, 可选) – 创建模块的设备。
示例
>>> import torch >>> from torchrl.modules import DdpgMlpActor >>> actor = DdpgMlpActor(action_dim=4) >>> print(actor) DdpgMlpActor( (mlp): MLP( (0): LazyLinear(in_features=0, out_features=400, bias=True) (1): ELU(alpha=1.0) (2): Linear(in_features=400, out_features=300, bias=True) (3): ELU(alpha=1.0) (4): Linear(in_features=300, out_features=4, bias=True) ) ) >>> obs = torch.zeros(10, 6) >>> action = actor(obs) >>> print(action.shape) torch.Size([10, 4])