Skip to content

Commit 8677557

Browse files
committed
Added commented paragraph
1 parent 430f634 commit 8677557

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

intermediate_source/reinforcement_q_learning.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,23 @@
9191
"cpu"
9292
)
9393

94-
# set the seeds for reproducibility
95-
seed = 42
96-
random.seed(seed)
97-
torch.manual_seed(seed)
98-
env.reset(seed=seed)
99-
env.action_space.seed(seed)
100-
env.observation_space.seed(seed)
101-
if torch.cuda.is_available():
102-
torch.cuda.manual_seed(seed)
94+
95+
# To ensure reproducibility during training, you can fix the random seeds
96+
# by uncommenting the lines below. This makes the results consistent across
97+
# runs, which is helpful for debugging or comparing different approaches.
98+
#
99+
# That said, allowing randomness can be beneficial in practice, as it lets
100+
# the model explore different training trajectories.
101+
102+
103+
# seed = 42
104+
# random.seed(seed)
105+
# torch.manual_seed(seed)
106+
# env.reset(seed=seed)
107+
# env.action_space.seed(seed)
108+
# env.observation_space.seed(seed)
109+
# if torch.cuda.is_available():
110+
# torch.cuda.manual_seed(seed)
103111

104112

105113
######################################################################

0 commit comments

Comments
 (0)