Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'data' #428

Open
ren01140201 opened this issue Apr 26, 2024 · 0 comments
Open

AttributeError: 'NoneType' object has no attribute 'data' #428

ren01140201 opened this issue Apr 26, 2024 · 0 comments

Comments

@ren01140201
Copy link

Error message: p.grad.data.mul_(1.0 / meta_batch_size)
AttributeError: 'NoneType' object has no attribute 'data'

For lines;
# Average the accumulated gradients and optimize
for p in maml.parameters():
print(p)
p.grad.data.mul_(1.0 / meta_batch_size)
opt.step()

I encountered the error message in #387 and did as recommended, added the parameter allow_unused=True.

Would it be wrong if I changed the aforementioned lines to:
with torch.no_grad():
for p in maml.parameters():
if p.grad is not None:
p.grad.data.mul_(1.0 / meta_batch_size)
opt.step()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant