Skip to content

AttributeError for gradient clipping #1

@andrewliao11

Description

@andrewliao11

hi ikostrikov, I got this error when running your code

Traceback (most recent call last):
  File "main.py", line 89, in <module>
    agent.update_parameters(batch)
  File "/home/andrewliao11/Work/pytorch-naf/naf.py", line 121, in update_parameters
    param.grad.data.clamp(-1, 1)
AttributeError: 'NoneType' object has no attribute 'data'

the original code is:

for param in self.model.parameters():
            param.grad.data.clamp(-1, 1)

maybe we should modify in into:

torch.nn.utils.clip_grad_norm(self.model.parameters(), 1)

I'm just a newbie to pytorch, not sure if it's right, thx!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions