# Flops counter for convolutional networks in pytorch framework
This script is designed to compute the theoretical amount of multiply-add operations
in convolutional neural networks. It also can compute the number of parameters and
print per-layer computational cost of a given network.
Supported layers:
- Convolution2d (including grouping)
- BatchNorm2d
- Activations (ReLU, PReLU, ELU, ReLU6, LeakyReLU)
- Linear
- Upsample
- Poolings (AvgPool2d, MaxPool2d and adaptive ones)
Requirements: Pytorch 0.4.1 or 1.0, torchvision 0.2.1
Thanks to @warmspringwinds for the initial version of script.
## Install
```bash
pip install git+https://github.com/sovrasov/flops-counter.pytorch.git
```
## Example
```python
import torchvision.models as models
import torch
from ptflops import get_model_complexity_info
with torch.cuda.device(0):
net = models.densenet161()
flops, params = get_model_complexity_info(net, (224, 224), as_strings=True, print_per_layer_stat=True)
print('Flops: ' + flops)
print('Params: ' + params)
```
This script is designed to compute the theoretical amount of multiply-add operations
in convolutional neural networks. It also can compute the number of parameters and
print per-layer computational cost of a given network.
Supported layers:
- Convolution2d (including grouping)
- BatchNorm2d
- Activations (ReLU, PReLU, ELU, ReLU6, LeakyReLU)
- Linear
- Upsample
- Poolings (AvgPool2d, MaxPool2d and adaptive ones)
Requirements: Pytorch 0.4.1 or 1.0, torchvision 0.2.1
Thanks to @warmspringwinds for the initial version of script.
## Install
```bash
pip install git+https://github.com/sovrasov/flops-counter.pytorch.git
```
## Example
```python
import torchvision.models as models
import torch
from ptflops import get_model_complexity_info
with torch.cuda.device(0):
net = models.densenet161()
flops, params = get_model_complexity_info(net, (224, 224), as_strings=True, print_per_layer_stat=True)
print('Flops: ' + flops)
print('Params: ' + params)
```
Metadata
Release files for ptflops 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ptflops-0.1.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ptflops-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / ptflops-0.1.tar.gz
| Download URL | ptflops-0.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b24fd5e04c9568e8269baad15545c3fe06a5265fd6e923141da83812b1a0563c
|
|
BLAKE2b-256 checksum How to use checksums |
cf207e928eb0aab7cf4a457dbe1b82404be8b8211751927691345ab11a463744
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.19.5 CPython/3.5.2
|
Release files / ptflops-0.1-py3-none-any.whl
| Download URL | ptflops-0.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fdb76159aa1957367e6a7d31dc69f85788164898174b0a27595dd5bd1c39fcf3
|
|
BLAKE2b-256 checksum How to use checksums |
fd48707af5fc4c87623b033d16ee0af4eb9310ed41e5881040cbdffa6fb9d7ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.19.5 CPython/3.5.2
|