Learning Deep Features for Discriminative Localization
# Learning Deep Features for Discriminative Localization
# 作者:Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, Antonio Torralba
# 单位:MIT
# 发表:CVPR 2016
# 摘要
# 阅读
# 论文的目的及结论
# 论文的实验
# 论文的方法
核心代码非常简单, 提取到特征图和目标类别全连接的权重,直接加权求和,再经过relu操作去除负值,最后归一化获取CAM,具体如下:
# 获取全连接层的权重
self._fc_weights = self.model._modules.get(fc_layer).weight.data
# 获取目标类别的权重作为特征权重
weights=self._fc_weights[class_idx, :]
# 这里self.hook_a为最后一层特征图的输出
batch_cams = (weights.unsqueeze(-1).unsqueeze(-1) * self.hook_a.squeeze(0)).sum(dim=0)
# relu操作,去除负值
batch_cams = F.relu(batch_cams, inplace=True)
# 归一化操作
batch_cams = self._normalize(batch_cams)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# 论文的背景
# 总结
# 论文的贡献
利用 GAP 获取 CAM 的开山之作
# 论文的不足
# 论文如何讲故事
# 参考资料
https://arxiv.org/abs/1512.04150
https://github.com/zhoubolei/CAM
- https://github.com/zhoubolei/CAM/blob/master/pytorch_CAM.py
https://cloud.tencent.com/developer/article/1674200
上次更新: 2021/11/03, 23:35:28
- 02
- README 美化05-20
- 03
- 常见 Tricks 代码片段05-12