MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / play_one_episode

Function play_one_episode

pytorch/rl_trader.py:353–368  ·  view source on GitHub ↗
(agent, env, is_train)

Source from the content-addressed store, hash-verified

351
352
353def play_one_episode(agent, env, is_train):
354 # note: after transforming states are already 1xD
355 state = env.reset()
356 state = scaler.transform([state])
357 done = False
358
359 while not done:
360 action = agent.act(state)
361 next_state, reward, done, info = env.step(action)
362 next_state = scaler.transform([next_state])
363 if is_train == 'train':
364 agent.update_replay_memory(state, action, reward, next_state, done)
365 agent.replay(batch_size)
366 state = next_state
367
368 return info['cur_val']
369
370
371

Callers 1

rl_trader.pyFile · 0.70

Calls 6

resetMethod · 0.45
transformMethod · 0.45
actMethod · 0.45
stepMethod · 0.45
update_replay_memoryMethod · 0.45
replayMethod · 0.45

Tested by

no test coverage detected