device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
net = D()  # 定义好的网络模型
if torch.cuda.is_available():
    net.cuda()
input1 = torch.randn(1, 3, 512, 512)#输入到模型时,模型要加一个维度x = x.unsqueeze(0)
input1 = input1.to(device)
#
input2 = torch.randn(1, 3, 512, 512)
input2 = input2.to(device)

flops, params = profile(net,inputs=(input1,input2))
print('flops: ', flops, 'params: ', params)


Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐