首页 > 编程知识 正文

pytorch计算,pytorch 矩阵运算

时间:2023-05-05 14:08:30 阅读:244273 作者:2013

需要使用官方库THOP: PyTorch-OpCounter
GitHub 地址:https://github.com/Lyken17/pytorch-OpCounter

1.安装THOP:

pip install thop # orpip install --upgrade git+https://github.com/Lyken17/pytorch-OpCounter.git

2.使用方法:

from torchvision.models import resnet50from thop import profile# 增加可读性from thop import clever_format# 可替换为自己的模型及输入model = resnet50()input = torch.randn(1, 3, 224, 224)flops, params = profile(model, inputs=(input, ))flops, params = clever_format([flops, params], "%.3f")

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。