0

hello everyone I followed that tutorial https://www.youtube.com/watch?v=hCeJeq8U0lo&list=PLgNJO2hghbmjlE6cuKMws2ejC54BTAaWV&index=2 to train a DQN Agent everything works

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))

now rather than make a random choice I want to use the DQN without having to do

dqn.test(env, steps=10)

something like dqn.predict but I did not find that in their documentation can you help please

1 Answers1

0
dqn.forward(state)

it is the same function in the code of the testing in its github repo https://github.com/taylormcnally/keras-rl2/blob/master/rl/agents/dqn.py