from thop import profile
class Test(nn.Module):
def __init__(self, input_size, output_szie):
super(Test, self).__init__()
self.out = nn.Linear(input_size, output_szie)
def forward(self, x):
output = self.out(x)
return output
t = Test(10, 2)
x = torch.randn(4, 10)
profile(t, (x,), verbose=False) # (80.0, 22.0): 10*2 + 2 = 22.0
# total_flops += flops
# model_params_num += params
profile计算模型参数
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
SGDMA与普通DMA
藍天上的雲℡
2024-05-02 14:21:20
用json来存数据的思路. json类型数据库的思路.
張博的博客
2024-05-02 14:19:50
Vue | babel.config.js 配置详解
emanlee
2024-05-02 14:10:29
Vue项目中main.js、App.vue、import...from...等的作用和意义
emanlee
2024-05-02 14:10:29
Vue .eslintignore
emanlee
2024-05-02 14:10:29
Vue mockjs mock.js
emanlee
2024-05-02 14:10:29
Vue .gitignore
emanlee
2024-05-02 14:10:29
vue 项目构建之 jsconfig.json 作用
emanlee
2024-05-02 14:10:29
Vue .eslintrc.js
emanlee
2024-05-02 14:10:29
Vue 生命周期 Vue进阶(三十六):created() 详解
emanlee
2024-05-02 14:10:29
Vue .browserslistrc
emanlee
2024-05-02 14:10:29
前端Vue 启动过程 启动流程 执行流程
emanlee
2024-05-02 14:10:29