From 3536d8e4b3f5020dd65c51a74861819eee52726c Mon Sep 17 00:00:00 2001 From: Tanay Wakhare Date: Sun, 12 Jul 2020 16:59:35 -0400 Subject: [PATCH] Masking error. With t*valid_mask, we get the error np.inf*0 = np.inf (#9407) --- rllib/agents/ppo/ppo_torch_policy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rllib/agents/ppo/ppo_torch_policy.py b/rllib/agents/ppo/ppo_torch_policy.py index 2d2f8e1fc..ec7611639 100644 --- a/rllib/agents/ppo/ppo_torch_policy.py +++ b/rllib/agents/ppo/ppo_torch_policy.py @@ -70,7 +70,7 @@ class PPOLoss: num_valid = torch.sum(valid_mask) def reduce_mean_valid(t): - return torch.sum(t * valid_mask) / num_valid + return torch.sum(t[valid_mask]) / num_valid else: @@ -195,7 +195,8 @@ class ValueNetworkMixin: np.asarray([prev_reward])), "is_training": False, }, [convert_to_torch_tensor(np.asarray([s])) for s in state], - convert_to_torch_tensor(np.asarray([1]))) + convert_to_torch_tensor( + np.asarray([1]))) return self.model.value_function()[0] else: