Skip to content

Commit

Permalink
Make it easier to see tensorboard
Browse files Browse the repository at this point in the history
  • Loading branch information
keiohta committed Jun 10, 2019
1 parent 36bed9b commit 9b07dc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tf2rl/algos/dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def train(self, states, actions, next_states, rewards, done, weights=None):
td_errors, q_func_loss = self._train_body(
states, actions, next_states, rewards, done, weights)

tf.summary.scalar(name="QFuncLoss", data=q_func_loss, description="loss")
tf.summary.scalar(name=self.policy_name+"/q_func_Loss", data=q_func_loss)

# TODO: Remove following by using tf.global_step
self.n_update += 1
Expand All @@ -191,7 +191,7 @@ def train(self, states, actions, next_states, rewards, done, weights=None):
# Update exploration rate
self.epsilon = max(self.epsilon - self.epsilon_decay_rate * self.update_interval,
self.epsilon_min)
tf.summary.scalar(name="Epsilon", data=self.epsilon, description="loss")
tf.summary.scalar(name=self.policy_name+"/epsilon", data=self.epsilon)

return td_errors

Expand Down
7 changes: 4 additions & 3 deletions tf2rl/experiments/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def __init__(

# prepare log directory
self._output_dir = prepare_output_dir(
args=args, user_specified_dir="./results", suffix=args.dir_suffix)
args=args, user_specified_dir="./results",
suffix="{}_{}".format(self._policy.policy_name, args.dir_suffix))
self.logger = logging.getLogger(__name__)
logging.basicConfig(
datefmt="%d/%Y %I:%M:%S",
Expand Down Expand Up @@ -104,8 +105,8 @@ def __call__(self):
avg_test_return = self.evaluate_policy(total_steps)
self.logger.info("Evaluation Total Steps: {0: 7} Average Reward {1: 5.4f} over {2: 2} episodes".format(
total_steps, avg_test_return, self._test_episodes))
tf.summary.scalar(name="Common/average_test_return", data=avg_test_return, description="loss")
tf.summary.scalar(name="Common/fps", data=fps, description="loss")
tf.summary.scalar(name="Common/average_test_return", data=avg_test_return)
tf.summary.scalar(name="Common/fps", data=fps)

self.writer.flush()

Expand Down

0 comments on commit 9b07dc8

Please sign in to comment.