class mindspore_rl.policy.GreedyPolicy(input_network)[源代码]

基于给定的贪婪策略生成采样动作。

参数:
  • input_network (Cell) - 用于按输入状态产生动作的网络。

样例:

>>> state_dim, hidden_dim, action_dim = 4, 10, 2
>>> input_net = FullyConnectedNet(state_dim, hidden_dim, action_dim)
>>> policy = GreedyPolicy(input_net)
>>> state = Tensor(np.ones([2, 4]).astype(np.float32))
>>> output = policy(state)
>>> print(output.shape)
(2,)
construct(state)[源代码]

返回最佳动作。

参数:
  • state (Tensor) - 网络的输入状态Tensor。

返回:

action_max,输出最佳动作。