0

大家好,我按照该教程 https://www.youtube.com/watch?v=hCeJeq8U0lo&list=PLgNJO2hghbmjlE6cuKMws2ejC54BTAaWV&index=2 训练 DQN 代理一切正常

env = gym.make('CartPole-v0')
states = env.observation_space.shape[0]
actions = env.action_space.n

episodes = 10
for episode in range(1, episodes+1):
    state = env.reset()
    done = False
    score = 0 
    
    while not done:
        env.render()
        action = random.choice([0,1])
        n_state, reward, done, info = env.step(action)
        score+=reward
    print('Episode:{} Score:{}'.format(episode, score))

现在我不想做一个随机的选择,我想使用 DQN 而不必做

dqn.test(env, steps=10)

类似 dqn.predict 但我没有在他们的文档中发现你能帮忙吗

4

1 回答 1

0
dqn.forward(state)

它在其 github 存储库 https://github.com/taylormcnally/keras-rl2/blob/master/rl/agents/dqn.py中的测试代码中具有相同的功能

于 2021-12-29T11:59:59.313 回答