From f98545266786baebc2749ad2315ccbd5ddb9afb2 Mon Sep 17 00:00:00 2001 From: Eugene Vinitsky Date: Wed, 23 Oct 2024 10:02:43 -0400 Subject: [PATCH] Update dqn.py If you do not make this change for recent torch you get the error raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") AttributeError: 'SonnetLinear' object has no attribute 'weight'. Did you mean: '_weight'? --- open_spiel/python/pytorch/dqn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open_spiel/python/pytorch/dqn.py b/open_spiel/python/pytorch/dqn.py index 0bb2bb6657..d4c68d55cd 100644 --- a/open_spiel/python/pytorch/dqn.py +++ b/open_spiel/python/pytorch/dqn.py @@ -396,9 +396,9 @@ def copy_with_noise(self, sigma=0.0, copy_weights=True): if copy_weights: with torch.no_grad(): for q_model in q_network.model: - q_model.weight *= (1 + sigma * torch.randn(q_model.weight.shape)) + q_model._weight *= (1 + sigma * torch.randn(q_model._weight.shape)) for tq_model in target_q_network.model: - tq_model.weight *= (1 + sigma * torch.randn(tq_model.weight.shape)) + tq_model._weight *= (1 + sigma * torch.randn(tq_model._weight.shape)) return copied_object def save(self, data_path, optimizer_data_path=None):