pytorch-hook
来源:互联网 发布:诲汝知之乎古诗文 编辑:程序博客网 时间:2024/06/05 22:39
1.
register_forward_hook(hook)
2.
register_backward_hook(hook)
/home/lyu/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.pyc in __call__(self, *input, **kwargs) 204 205 def __call__(self, *input, **kwargs):--> 206 result = self.forward(*input, **kwargs) 207 for hook in self._forward_hooks.values(): 208 hook_result = hook(self, input, result)
eg.
dic = {}
def get_fea(name):
def hook(m, x, y):
dic[name] = y
return hook
mm.conv1.register_forward_hook(get_fea('conv1'))
..
mm(x)
...
--------------------------reference------------------------------------
1. https://github.com/jacobgil/pytorch-grad-cam/blob/master/grad-cam.py
2. http://blog.csdn.net/u012436149/article/details/69230136
3. https://discuss.pytorch.org/t/why-cant-i-see-grad-of-an-intermediate-variable/94/6 ***
4. https://discuss.pytorch.org/t/why-cant-i-see-grad-of-an-intermediate-variable/94/12
阅读全文
0 0
- pytorch-hook
- pytorch学习笔记(七):pytorch hook 和 关于pytorch backward过程的理解
- pytorch学习笔记(七):pytorch hook 和 关于pytorch backward过程的理解
- PyTorch
- PyTorch
- PyTorch
- pytorch
- pytorch
- Pytorch
- Pytorch是什么?关于Pytorch
- hook
- HOOK
- hook
- Hook
- Hook
- hook
- Hook
- Hook
- OpenGL学习(一)——画一个三角形
- MD5应用于数据库中密码加密
- 机器学习框架比较
- JSON与XML的区别比较
- 使用Eclipse创建Maven Web工程
- pytorch-hook
- Replay the test case using KLEE
- js之基础篇三
- SpringSide实战(二)----运行SpringSide项目并导入到Eclipse中
- 比特币
- 广播接收者--有序广播
- 记录从指尖悄悄流逝的时间
- tensorflow基于GPU环境配置
- The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class fi