yizt / Grad-CAM.pytorch

pytorch实现Grad-CAM和Grad-CAM++,可以可视化任意分类网络的Class Activation Map (CAM)图,包括自定义的网络;同时也实现了目标检测faster r-cnn和retinanet两个网络的CAM图;欢迎试用、关注并反馈问题...
Apache License 2.0
729 stars 167 forks source link

Grad_cam++的实现和原文的计算公式不一致,请问怎么理解 #35

Open zgf6781882 opened 3 years ago

zgf6781882 commented 3 years ago
    norm_factor = np.sum(gradient, axis=(1, 2))  # [C]归一化
    for i in range(len(norm_factor)):
        norm_factor[i] = 1. / norm_factor[i] if norm_factor[i] > 0. else 0.  # 避免除零
    alpha = indicate * norm_factor[:, np.newaxis, np.newaxis]  # [C,H,W]

请问怎么理解alpha的计算啊?

yizt commented 3 years ago

image

@zgf6781882 以上是计算一个通道的alpha过程示例

zhailei-zl commented 2 years ago

您好,这部分alpha的计算中,和原论文公式怎么对应呢,原论文中的alpha计算中分母含有梯度乘特征图并进行求和

mlerma54 commented 2 years ago

Hello, this way of computing the alphas will cause all weights to be 1, and does not mach the original paper (eq. 19 in https://arxiv.org/abs/1710.11063). Can you please elaborate? Thank you!