强化学习 - 动作次数

reinforcement learning - number of actions

阅读 https://towardsdatascience.com/reinforcement-learning-temporal-difference-sarsa-q-learning-expected-sarsa-on-python-9fecfda7467e epsilon_greedy 定义为:

def epsilon_greedy(Q, epsilon, n_actions, s, train=False):
    """
    @param Q Q values state x action -> value
    @param epsilon for exploration
    @param s number of states
    @param train if true then no random actions selected
    """
    if train or np.random.rand() < epsilon:
        action = np.argmax(Q[s, :])
    else:
        action = np.random.randint(0, n_actions)
    return action

参数n_actions是代理可用的操作数吗?因此,如果代理正在学习踢足球并且可用的动作是{踢,不踢} n_actions = 2

是的,你是对的。通常,您定义一个字典,其中包含整数与您的代理可以执行的每个操作之间的映射。您可以看到在函数中 n_actions 恰好用于在您不 select 最佳索引时对随机动作索引进行采样。