-
Notifications
You must be signed in to change notification settings - Fork 280
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: 'list' object has no attribute 'grad_fn' #31
Comments
does your model output a list? |
@caffelearn @szagoruyko |
i also meet this problem and yes, my model output a list could you help me? @szagoruyko
how do you solve this? @caffelearn @H-YunHui |
@Light-- I was able to resolve this by passing a tuple containing the output list's elements. For example if your model has 3 outputs which you output as elements of a list called 'y', then the make_dot function would look like this: vis_graph = make_dot((y[0], y[1], y[2]), params=dict(list(self.model.named_parameters()) )) |
@chesharma
Genius bro! 👍 👍 👍 How did you notice this problem and figure it out ?
thanks @chesharma |
File "C:\Users\admin\AppData\Local\conda\conda\envs\pytorch\lib\site-packages\torchviz\dot.py", line 38, in make_dot
output_nodes = (var.grad_fn,) if not isinstance(var, tuple) else tuple(v.grad_fn for v in var)
AttributeError: 'list' object has no attribute 'grad_fn'
use:
x= torch.randn(1, 3, 800, 800)
y = self.model.cpu()(x)
vis_graph = make_dot(y, params=dict(list(self.model.named_parameters()) ))
The text was updated successfully, but these errors were encountered: