首页 > 其他 > 详细

profile计算模型参数

时间:2020-10-25 22:46:45      阅读:149      评论:0      收藏:0      [点我收藏+]
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计算模型参数

原文:https://www.cnblogs.com/douzujun/p/13875078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!