Comments (5)
@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.
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.
@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.
@ChristineRYY
M = 1024 ^ 2
G = 1024 ^ 3
from pytorch-opcounter.
@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)
- question about the MACs of nn.BatchNorm2d
- got 0 ops for nn.MultiheadAttention HOT 7
- Count flops by a range
- thop/profile.py:12: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. `if LooseVersion(torch.__version__) < LooseVersion("1.0.0"):` HOT 2
- Does MACs and FLOPs count correctly for and INT8 quantized model? HOT 1
- Upload sdist to PyPI HOT 1
- Problem in bert HOT 1
- multiple inputs HOT 1
- Is the latest version calculate MACs or FLOPs HOT 2
- RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
- How to calculate the FLOPs of each type of layers?
- How to exclude flops of 1st input? HOT 1
- Incorrect macs without specifying batch size for conv layers
- will torch.matmul regards as zero_ops ?
- Is thop also effective for calculating Flops for spiking neural networks?
- rename calculate_conv2d_flops HOT 1
- thop calculates torch.nn module params incorrectly HOT 1
- RuntimeError: Can't add a new parameter
- count_normalization is only correct for batch_norm. wrong flops count for layernorm HOT 1
- Res add will be included when evaluate Resnet's OPs ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-opcounter.