torch-cam icon indicating copy to clipboard operation
torch-cam copied to clipboard

What is class_idx in __call__() ??

Open edwardcho opened this issue 2 years ago • 5 comments

Hello sir, I want to display heat-map for my classification task. So i found your library. What is class_idx of call()?? (I think that it is class index of top-1)

And, Using my datasets, I met nan. In compute_cam() of core.py My result of torch.nansum has all < 0. Then F.relu return all 0. So, in normalization, it return nan.

Is this nornal?? If not, what should i change in my data??

Thanks. Edward cho

edwardcho avatar Apr 26 '22 00:04 edwardcho

Hi there 👋

a CAM is relative to the class output of the model, not necessarily the top 1. So this arg needs to be an integer in the range of (0, N - 1) where N is the number of output classes ;)

Regarding your error, I would need a minimal runnable snippet to reproduce as I'm not sure what you mean here :/ For issues, it's better to fill the bug report template next time please 🙏

Cheers ✌️

frgfm avatar Apr 26 '22 23:04 frgfm

Hi there 👋

a CAM is relative to the class output of the model, not necessarily the top 1. So this arg needs to be an integer in the range of (0, N - 1) where N is the number of output classes ;)

Regarding your error, I would need a minimal runnable snippet to reproduce as I'm not sure what you mean here :/ For issues, it's better to fill the bug report template next time please 🙏

Cheers ✌️

Hello sir. As you know, the CAM is for checking of decision of deep learning tasks, i think. So i want to use evidence of top-1 on classification task. If so, class-idx should be class index of top-1. Right??

Thanks, Edward cho

edwardcho avatar Apr 27 '22 00:04 edwardcho

If so, class-idx should be class index of top-1. Right??

As mentioned above, yes you can!

However regarding your error, I'll need a runnable snippet to reproduce this behaviour 🙏

frgfm avatar Apr 27 '22 00:04 frgfm

Any update @edwardcho ? :)

frgfm avatar May 16 '22 23:05 frgfm

Hello @edwardcho :wave:

Mind providing a minimal script to reproduce the behavior you described? :pray: Otherwise I'll close the issue since I cannot do anything about this without more details :sweat_smile:

frgfm avatar Aug 01 '22 21:08 frgfm

The NaN problem you mention is fixed by #185. For the rest, I have no way of reproducing it, so I'm closing the issue! Feel free to reopen if you encounter some trouble :)

frgfm avatar Sep 18 '22 11:09 frgfm