Skip to content

Commit

Permalink
Update dqn.py
Browse files Browse the repository at this point in the history
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'?
  • Loading branch information
eugenevinitsky authored Oct 23, 2024
1 parent 2228e1c commit f985452
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions open_spiel/python/pytorch/dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f985452

Please sign in to comment.