Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliagusak/flopco-pytorch
FLOPs and other statistics COunter for Pytorch neural networks
https://github.com/juliagusak/flopco-pytorch
cnn flops macs neural-networks pytorch
Last synced: about 2 months ago
JSON representation
FLOPs and other statistics COunter for Pytorch neural networks
- Host: GitHub
- URL: https://github.com/juliagusak/flopco-pytorch
- Owner: juliagusak
- License: mit
- Created: 2019-10-10T18:14:50.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-27T11:09:41.000Z (over 3 years ago)
- Last Synced: 2024-11-01T15:07:03.798Z (2 months ago)
- Topics: cnn, flops, macs, neural-networks, pytorch
- Language: Python
- Size: 30.3 KB
- Stars: 23
- Watchers: 3
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
FlopCo
=====FlopCo is a Python library that aims to make FLOPs and MACs counting simple and accessible for Pytorch neural networks.
Moreover FlopCo allows to collect other useful model statistics, such as number of parameters, shapes of layer inputs/outputs, etc.Requirements
-----
- numpy
- pytorchInstallation
-----
```pip install flopco-pytorch ```Quick start
-----
```python
from flopco import FlopCo
from torchvision.models import resnet50device = 'cuda'
model = resnet50().to(device)# Estimate model statistics by making one forward pass througth the model,
# for the input image of size 3 x 224 x 224stats = FlopCo(model, img_size = (1, 3, 224, 224), device = device)
print(stats.total_macs, stats.relative_flops)
```List of estimated statistics includes:
- total number of FLOPs/MACs/parameters
- number of FLOPs/MACs/parameters for each layer
- relative number of FLOPs/MACs/parameters for each layer
- input/output shapes for each layerBy default for statistics counting nn.Conv2d and nn.Linear layers are used.
To include more layer types in computation, pass ```instances``` to the constructor```python
stats = FlopCo(model,
img_size = (1, 3, 224, 224),
device = device,
instances = [nn.Conv2d, nn.Linear,\
nn.BatchNorm2d, nn.ReLU,\
nn.MaxPool2d, nn.AvgPool2d,\
nn.Softmax]
)
```License
-----Project is distributed under [MIT License](https://github.com/juliagusak/flopco-pytorch/blob/master/LICENSE.txt)