当前位置:   article > 正文

Pytorch 中计算Flops和Params_flops, params = profile(model, inputs=(input, )

flops, params = profile(model, inputs=(input, )

如下,越来越喜欢用Pytorch

import torch
from thop import profile
from torchvision.models import resnet18

# 创建一个示例输入
input = torch.randn(1, 3, 224, 224)

# 加载您的模型
model = MV2_CBAM_Shuffle()

# 使用thop.profile()函数计算模型的FLOPs
flops, params = profile(model, inputs=(input,))

print(f"FLOPs: {flops}, Params: {params}")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/974311
推荐阅读
相关标签
  

闽ICP备14008679号