# -- coding: utf-8 --
import torch
import torchvision
from thop import profile
# Model
print('==> Building model..')
model = torchvision.models.alexnet(pretrained=False)
dummy_input = torch.randn(1, 3, 224, 224)
flops, params = profile(model, (dummy_input,))
print('flops: ', flops, 'params: ', params)
print('flops: %.2f M, params: %.2f M' % (flops / 1000000.0, params / 1000000.0))
# -- coding: utf-8 -- import torchvision from ptflops import get_model_complexity_info model = torchvision.models.alexnet(pretrained=False) flops, params = get_model_complexity_info(model, (3, 224, 224), as_strings=True, print_per_layer_stat=True) print('flops: ', flops, 'params: ', params)
标签:11,224,params,print,import,model,flops From: https://www.cnblogs.com/yyhappy/p/17843287.html