Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit b5bf6ae

Browse files
author
Islam Elnabarawy
committed
Fix error in the way learners check for the presence of a summary writer
The way they were checking causes an exception if the summary writer is None
1 parent f3f2321 commit b5bf6ae

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

rl/neural_q_learner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def updateModel(self):
193193
next_state_mask[k] = 1
194194

195195
# whether to calculate summaries
196-
calculate_summaries = self.train_iteration % self.summary_every == 0 and self.summary_writer is not None
196+
calculate_summaries = self.summary_writer is not None and self.train_iteration % self.summary_every == 0
197197

198198
# perform one update of training
199199
cost, _, summary_str = self.session.run([

rl/pg_actor_critic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def updateModel(self):
190190
discounted_rewards[t] = r
191191

192192
# whether to calculate summaries
193-
calculate_summaries = self.train_iteration % self.summary_every == 0 and self.summary_writer is not None
193+
calculate_summaries = self.summary_writer is not None and self.train_iteration % self.summary_every == 0
194194

195195
# update policy network with the rollout in batches
196196
for t in range(N-1):

rl/pg_ddpg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def updateModel(self):
205205
next_state_mask[k] = 1
206206

207207
# whether to calculate summaries
208-
calculate_summaries = self.train_iteration % self.summary_every == 0 and self.summary_writer is not None
208+
calculate_summaries = self.summary_writer is not None and self.train_iteration % self.summary_every == 0
209209

210210
# compute a = u(s)
211211
policy_outs = self.session.run(self.policy_outputs, {

rl/pg_reinforce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def updateModel(self):
174174
discounted_rewards /= np.std(self.all_rewards)
175175

176176
# whether to calculate summaries
177-
calculate_summaries = self.train_iteration % self.summary_every == 0 and self.summary_writer is not None
177+
calculate_summaries = self.summary_writer is not None and self.train_iteration % self.summary_every == 0
178178

179179
# update policy network with the rollout in batches
180180
for t in range(N-1):

0 commit comments

Comments
 (0)