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

An error when I thied to use my .pth file #38

Open
wuaodi opened this issue May 5, 2021 · 0 comments
Open

An error when I thied to use my .pth file #38

wuaodi opened this issue May 5, 2021 · 0 comments

Comments

@wuaodi
Copy link

wuaodi commented May 5, 2021

The difference between my model and resnet50 is only the last 3 layers,shown as below:

(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=2048, out_features=1000, bias=True)
)
(bottleneck): Sequential(
(0): AdaptiveAvgPool2d(output_size=(1, 1))
(1): Flatten(start_dim=1, end_dim=-1)
)
(head): Linear(in_features=2048, out_features=7, bias=True)

The error

  warnings.warn("Using a non-full backward hook when the forward contains multiple autograd Nodes "
Traceback (most recent call last):
  File "main_wad.py", line 236, in <module>
    main()
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "main_wad.py", line 206, in demo4
    probs, ids = gcam.forward(images)
  File "/content/grad-cam-pytorch/grad_cam.py", line 31, in forward
    self.logits = self.model(image)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 893, in _call_impl
    hook_result = hook(self, input, result)
  File "/content/grad-cam-pytorch/grad_cam.py", line 118, in forward_hook
    self.fmap_pool[key] = output.detach()
AttributeError: 'tuple' object has no attribute 'detach'

Thank you so much!

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