当前位置:网站首页>Pytoch modifies the hook source code to obtain per layer output parameters (with layer name)
Pytoch modifies the hook source code to obtain per layer output parameters (with layer name)
2022-06-30 01:31:00 【Martin の Blog】
I want to use hook When obtaining the output parameters of each layer .
call pytorch Medium API, It is found that there is no good method to print the layer name and parameters of each layer one-to-one
For this reason, it is modified hook Source code , Just call again .
import torch
import torch.utils.hooks as hooks
def get_output_param(module, datasets):
output_param = {
}
def hook(module, input, output):
name = list(module._forward_hooks.keys())[0]
output_param[name] = output.data
for name, layer in module.named_modules():
if name != "":
handle = hooks.RemovableHandle(layer._forward_hooks)
layer._forward_hooks[f"{
name}"] = hook
module(datasets)
return output_param
end
边栏推荐
- JS prototype and prototype chain (Lantern Festival meal)
- 一文读懂,MES管理系统模块功能
- 存储引擎分析
- Stimulus reports reporting tool, stimulus creates and builds reports
- The 8th "Internet +" competition - cloud native track invites you to challenge
- 【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类
- MySQL monitoring 3
- Varnish foundation overview 2
- MES管理系统功能模块之质量管理
- Interface Association of postman
猜你喜欢

Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object

cookie加密9

Preliminary understanding of NVIDIA Jetson nano

cookie加密11

Cub school learning: manual query and ADC in-depth use

Cookie加密12

Is the numpy index the same as the image index?

Ctfshow competition original title 680-695

ES6 one line code for array de duplication

C语言 说反话
随机推荐
C语言 写出这个数
Mysql 监控
C语言 换个格式输出整数
【二叉树】最大二叉树 II
Difference between test plan and test plan
Rubymine development tool, refactoring and intention operation
一文读懂,MES管理系统模块功能
Varnish foundation overview 10
I, 33 years old, ByteDance test development, unveiled the real income of Beijing "test post"
Cookie encryption 11
“乘风破浪”的芒果超媒,能上岸吗?
Embedded test template
Varnish foundation overview 5
c语言期末不挂科(上)
Cookie加密13
【机器学习Q&A】准确率、精确率、召回率、ROC和AUC
Some thoughts on small program subcontracting and verification of uiniapp subcontracting optimization logic
【535. TinyURL 的加密与解密】
MES管理系统功能模块之质量管理
Tetris game based on STM32F103