How to use the thop.clever_format function in thop

To help you get started, we’ve selected a few thop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xieydd / Pytorch-Single-Path-One-Shot-NAS / utils / count_flops.py View on Github external
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)
github wlguan / MobileNet-v2-pruning / models / vgg.py View on Github external
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)
github xieydd / Pytorch-Single-Path-One-Shot-NAS / model / network.py View on Github external
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)
github ElvishElvis / 68-Retinaface-Pytorch-version / mobile.py View on Github external
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)

thop

A tool to count the FLOPs of PyTorch model.

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages