方法1:
https://github.com/Lyken17/pytorch-OpCounter
from torchvision.models import resnet50
from thop import profile
model = resnet50()
input = torch.randn(1, 3, 224, 224)
flops, params = profile(model, inputs=(input, ))
方法2:
import torch
import torchvision.models as models
from torchsummary import summary
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = models.resnet18().to(device)
summary(model, (3,256,256))
善始者众,善终者寡