Giter VIP home page Giter VIP logo

Comments (5)

Lyken17 avatar Lyken17 commented on July 18, 2024 1

@zpkosmos There are some bugs in my previous counting implementations. I have updated the readme to match the latest version. Please check it out.

Besides, you can generate the table using

import torch
from torchvision import models
from thop.profile import profile

model_names = sorted(name for name in models.__dict__ if
                     name.islower() and not name.startswith("__") and not "inception" in name
                     and callable(models.__dict__[name]))

print("%s | %s | %s" % ("Model", "Params(M)", "FLOPs(G)"))
print("---|---|---")

device = "cpu"
if torch.cuda.is_available():
    device = "cuda"
for name in model_names:
    model = models.__dict__[name]().to(device)
    inputs = torch.randn((1, 3, 224, 224)).to(device)
    total_ops, total_params = profile(model, (inputs, ), verbose=False)
    print("%s | %.2f | %.2f" % (name, total_params / (1024 ** 2), total_ops / (1024 ** 3)))

from pytorch-opcounter.

SWHL avatar SWHL commented on July 18, 2024

I have the same result with @ustclj after running the following code:

from torchvision.models import resnet50 
from thop import profile 
model = resnet50() 
flops, params = profile(model, input_size=(1, 3, 224,224))
print(flops, params)

Result:

flops: 4142627840.0
params: 25557032.0

Environment:

PyTorch: 1.0.0

from pytorch-opcounter.

PearlDzzz avatar PearlDzzz commented on July 18, 2024

@Lyken17 I get the same result. But I don't know what the units of flops and params are. And how to convert them to M and G?

from pytorch-opcounter.

Lyken17 avatar Lyken17 commented on July 18, 2024

@ChristineRYY
M = 1024 ^ 2
G = 1024 ^ 3

from pytorch-opcounter.

zpkosmos avatar zpkosmos commented on July 18, 2024

@Lyken17
It seems that 4142713856.0=3.858G
However,in your README,it is 3.53G what is the problem?

from pytorch-opcounter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.