Minor update

This commit is contained in:
Shangtong Zhang
2018-04-10 23:40:45 -06:00
parent bb5ef4fbfc
commit e1df46aeec
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ class PPOAgent(BaseAgent):
obj = ratio * sampled_advantages
obj_clipped = ratio.clamp(1.0 - self.config.ppo_ratio_clip,
1.0 + self.config.ppo_ratio_clip) * sampled_advantages
policy_loss = -torch.min(obj, obj_clipped).mean(0) + config.entropy_weight * entropy_loss.mean(0)
policy_loss = -torch.min(obj, obj_clipped).mean(0) + config.entropy_weight * entropy_loss
value_loss = 0.5 * (sampled_returns - values).pow(2).mean()
+1 -1
View File
@@ -199,7 +199,7 @@ class DiscreteActorCriticWrapper:
if action is None:
action = dist.sample()
log_prob = dist.log_prob(action).unsqueeze(1)
return action, log_prob, entropy_loss, value
return action, log_prob, entropy_loss.mean(0), value
def variable(self, x, dtype=torch.FloatTensor):
return self.network.variable(x, dtype)