Skip to content

Commit d4b1ee1

Browse files
committed
update target network weight during episode after x timesteps
1 parent e6a97be commit d4b1ee1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

intermediate_source/reinforcement_q_learning.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,10 @@ def optimize_model():
492492
episode_durations.append(t + 1)
493493
plot_durations()
494494
break
495-
# Update the target network, copying all weights and biases in DQN
496-
if i_episode % TARGET_UPDATE == 0:
497-
target_net.load_state_dict(policy_net.state_dict())
495+
496+
# Update the target network, copying all weights and biases in DQN
497+
if t % TARGET_UPDATE == 0:
498+
target_net.load_state_dict(policy_net.state_dict())
498499

499500
print('Complete')
500501
env.render()

0 commit comments

Comments
 (0)