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

get AttributeError: grad_fn when use make_dot #14

Closed
Pinnh opened this issue Jun 10, 2017 · 1 comment · Fixed by #15
Closed

get AttributeError: grad_fn when use make_dot #14

Pinnh opened this issue Jun 10, 2017 · 1 comment · Fixed by #15

Comments

@Pinnh
Copy link

Pinnh commented Jun 10, 2017

when I use following code to visualize the torch pretrained resnet18 model, I get AttributeError: grad_fn, at line: add_nodes(var.grad_fn)

input=torch.randn(1,3,224,224)  
model=models.resnet18(pretrained=True)
for param in model.parameters():
     param.requires_grad = True
params = model.state_dict()
y=model(Variable(input))
print y
dot=make_dot(y, params)
@szagoruyko
Copy link
Owner

@Pinnh that's because model.state_dict() returns a dict of tensors, whereas make_dot expects a dict of Variables. I don't think there's a method that returns such dict for a model, so for now the best solution would probably be to make the params argument optional.

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

Successfully merging a pull request may close this issue.

2 participants