All Projects → 1adrianb → Pytorch Estimate Flops

1adrianb / Pytorch Estimate Flops

Licence: bsd-3-clause
Estimate/count FLOPS for a given neural network using pytorch

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytorch Estimate Flops

Lsuvinit
Reference caffe implementation of LSUV initialization
Stars: ✭ 99 (-10%)
Mutual labels:  convolutional-neural-networks
Tiny Faces Pytorch
Finding Tiny Faces in PyTorch
Stars: ✭ 105 (-4.55%)
Mutual labels:  convolutional-neural-networks
Exermote
Using Machine Learning to predict the type of exercise from movement data
Stars: ✭ 108 (-1.82%)
Mutual labels:  convolutional-neural-networks
Ynet
Y-Net: Joint Segmentation and Classification for Diagnosis of Breast Biopsy Images
Stars: ✭ 100 (-9.09%)
Mutual labels:  convolutional-neural-networks
Wav2letter.pytorch
A fully convolution-network for speech-to-text, built on pytorch.
Stars: ✭ 104 (-5.45%)
Mutual labels:  convolutional-neural-networks
Ghostnet
CV backbones including GhostNet, TinyNet and TNT, developed by Huawei Noah's Ark Lab.
Stars: ✭ 1,744 (+1485.45%)
Mutual labels:  convolutional-neural-networks
Awslambdaface
Perform deep neural network based face detection and recognition in the cloud (via AWS lambda) with zero model configuration or tuning.
Stars: ✭ 98 (-10.91%)
Mutual labels:  convolutional-neural-networks
Alexnet Experiments Keras
Code examples for training AlexNet using Keras and Theano
Stars: ✭ 109 (-0.91%)
Mutual labels:  convolutional-neural-networks
Idn Caffe
Caffe implementation of "Fast and Accurate Single Image Super-Resolution via Information Distillation Network" (CVPR 2018)
Stars: ✭ 104 (-5.45%)
Mutual labels:  convolutional-neural-networks
Steady State Flow With Neural Nets
A Tensorflow re-implementation of the paper Convolutional Neural Networks for Steady Flow Approximation
Stars: ✭ 107 (-2.73%)
Mutual labels:  convolutional-neural-networks
Keras Video Classifier
Keras implementation of video classifier
Stars: ✭ 100 (-9.09%)
Mutual labels:  convolutional-neural-networks
Sigmoidal ai
Tutoriais de Python, Data Science, Machine Learning e Deep Learning - Sigmoidal
Stars: ✭ 103 (-6.36%)
Mutual labels:  convolutional-neural-networks
Mp Cnn Torch
Multi-Perspective Convolutional Neural Networks for modeling textual similarity (He et al., EMNLP 2015)
Stars: ✭ 106 (-3.64%)
Mutual labels:  convolutional-neural-networks
Antialiased Cnns
pip install antialiased-cnns to improve stability and accuracy
Stars: ✭ 1,363 (+1139.09%)
Mutual labels:  convolutional-neural-networks
Shot Type Classifier
Detecting cinema shot types using a ResNet-50
Stars: ✭ 109 (-0.91%)
Mutual labels:  convolutional-neural-networks
Cutmix
a Ready-to-use PyTorch Extension of Unofficial CutMix Implementations with more improved performance.
Stars: ✭ 99 (-10%)
Mutual labels:  convolutional-neural-networks
Self Driving Car
Automated Driving in NFS using CNN.
Stars: ✭ 105 (-4.55%)
Mutual labels:  convolutional-neural-networks
Densepoint
DensePoint: Learning Densely Contextual Representation for Efficient Point Cloud Processing (ICCV 2019)
Stars: ✭ 110 (+0%)
Mutual labels:  convolutional-neural-networks
Facedet
实现常用基于深度学习的人脸检测算法
Stars: ✭ 109 (-0.91%)
Mutual labels:  convolutional-neural-networks
Sod
An Embedded Computer Vision & Machine Learning Library (CPU Optimized & IoT Capable)
Stars: ✭ 1,460 (+1227.27%)
Mutual labels:  convolutional-neural-networks

License Test Pytorch Flops Counter PyPI

pytorch-estimate-flops

Simple pytorch utility that estimates the number of FLOPs for a given network. For now only some basic operations are supported (basically the ones I needed for my models). More will be added soon.

All contributions are welcomed.

Installation

You can install the model using pip:

pip install pthflops

or directly from the github repository:

git clone https://github.com/1adrianb/pytorch-estimate-flops && pytorch-estimate-flops
python setup.py install

Note: pytorch 1.8 or newer is recommended.

Example

import torch
from torchvision.models import resnet18

from pthflops import count_ops

# Create a network and a corresponding input
device = 'cuda:0'
model = resnet18().to(device)
inp = torch.rand(1,3,224,224).to(device)

# Count the number of FLOPs
count_ops(model, inp)

Ignoring certain layers:

import torch
from torch import nn
from pthflops import count_ops

class CustomLayer(nn.Module):
    def __init__(self):
        super(CustomLayer, self).__init__()
        self.conv1 = nn.Conv2d(5, 5, 1, 1, 0)
        # ... other layers present inside will also be ignored

    def forward(self, x):
        return self.conv1(x)

# Create a network and a corresponding input
inp = torch.rand(1,5,7,7)
net = nn.Sequential(
    nn.Conv2d(5, 5, 1, 1, 0),
    nn.ReLU(inplace=True),
    CustomLayer()
)

# Count the number of FLOPs, jit mode:
count_ops(net, inp, ignore_layers=['CustomLayer'])

# Note: if you are using python 1.8 or newer with fx instead of jit, the naming convention changed. As such, you will have to pass ['_2_conv1']
# Please check your model definition to account for this.
# Count the number of FLOPs, fx mode:
count_ops(net, inp, ignore_layers=['_2_conv1'])

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].