leftthomas / GradCAM

A PyTorch implementation of Grad-CAM based on ICCV 2017 paper "Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization"
56 stars 13 forks source link

I have a question about backpropagation #3

Open hongnianwang opened 4 years ago

hongnianwang commented 4 years ago

https://github.com/leftthomas/GradCAM/blob/f082a578e6dff8a5c5bb54bcc104d11c57758cd3/gradcam.py#L36

            classes = F.sigmoid(feature) #feature shape=[1,1], classes shape=[1,1]
            one_hot, _ = classes.max(dim=-1) # one_hot shape=[1]
            self.model.zero_grad()
            one_hot.backward()

This one_hot is not the one hot label, I don't know it is correct or not,

In my experiment, there is a class without any activation hot map. Did you know why? Thanks