Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_resnet50_thop():
model = resnet50()
input = torch.randn(1,3,224,224)
flops, params = profile(model, inputs=(input,))
flops, params = clever_format([flops, params], "%.3f")
print("flops: ", flops, "params: ", params)
elif isinstance(m, nn.Linear):
m.weight.data.normal_(0, 0.01)
m.bias.data.zero_()
if __name__ == '__main__':
import thop
vgg = VGG()
input = torch.randn(1, 3, 32, 32)
output = vgg(input)
print(output.shape)
flops, params = thop.profile(vgg, inputs=(input,), verbose=False)
flops, params = thop.clever_format([flops, params], "%.3f")
print(flops, params)
def get_flops(model):
input = torch.randn(1,3,224,224)
# flops, params = profile(model, input=(input, ), custom_ops={model: count_flops})
flops, params = profile(model, inputs=(input, ))
flops, params = clever_format([flops, params], "%.3f")
print('flops: ', flops, 'params: ', params)
x26 = self.mobilenet0_conv26(x)
result_[1]=x10
result_[2]=x22
result_[3]=x26
return result_
if __name__ == "__main__":
from thop import profile
net = mobileV1()
torch.save(net.state_dict(),'a.ttt')
from thop import profile
from thop import clever_format
# x = torch.randn(1,3,320,320)
input = torch.randn(1, 3, 224, 224)
flops, params = profile(net, inputs=(input, ))
flops, params = clever_format([flops, params], "%.3f")
print(params)
print(flops)