From 823bda6fee2ff77228a8621d85efbcdab9f33a8f Mon Sep 17 00:00:00 2001 From: Mike C Date: Mon, 22 Jan 2018 13:52:16 +0800 Subject: [PATCH] log noise --- agent/DDPG_agent.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agent/DDPG_agent.py b/agent/DDPG_agent.py index 5d32be5..24a372e 100644 --- a/agent/DDPG_agent.py +++ b/agent/DDPG_agent.py @@ -8,7 +8,7 @@ import numpy as np import torch from torch.autograd import Variable import torch.nn as nn -from component import Normalizer +from utils.normalizer import Normalizer class DDPGAgent: @@ -68,7 +68,10 @@ class DDPGAgent: actor.eval() action = actor.predict(np.stack([state])).flatten() if not deterministic: - action += self.random_process.sample() + noise = self.random_process.sample() + else: + noise = 0 + action += noise next_state, reward, done, info = self.task.step(action) if video_recorder is not None: video_recorder.capture_frame() @@ -76,12 +79,16 @@ class DDPGAgent: next_state = self.state_normalizer(next_state) total_reward += reward + assert np.isfinite(action), 'action should be finite' + # tensorboard logging suffix = 'test_' if deterministic else '' if action.squeeze().ndim == 0: config.logger.scalar_summary(suffix + 'action', action, self.total_steps) + config.logger.scalar_summary(suffix + 'noise', noise, self.total_steps) else: config.logger.histo_summary(suffix + 'action', action, self.total_steps) + config.logger.histo_summary(suffix + 'noise', noise, self.total_steps) config.logger.scalar_summary(suffix + 'reward', reward, self.total_steps) for key in info: config.logger.scalar_summary('info_' + key, info[key], self.total_steps)