From 7c1f72c033948d1ce795d7759596064fac954009 Mon Sep 17 00:00:00 2001 From: masus Date: Sat, 18 Aug 2018 11:36:36 +0200 Subject: [PATCH] Attempt to fix Reinforce inf problem --- Othello/players/reinforcePlayer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Othello/players/reinforcePlayer.py b/Othello/players/reinforcePlayer.py index 701bcc3..8e6d206 100644 --- a/Othello/players/reinforcePlayer.py +++ b/Othello/players/reinforcePlayer.py @@ -43,7 +43,7 @@ def update(self): policy_losses = [(-log_prob * reward) for log_prob, reward in zip(self.log_probs, rewards)] self.optimizer.zero_grad() - policy_loss = torch.cat(policy_losses).sum()/len(policy_losses) + policy_loss = torch.mean(policy_losses) policy_loss.backward() self.optimizer.step()