Coder Social home page Coder Social logo

How to measure MACs? about poolformer HOT 5 CLOSED

DoranLyong avatar DoranLyong commented on June 19, 2024
How to measure MACs?

from poolformer.

Comments (5)

yuweihao avatar yuweihao commented on June 19, 2024 1

Hi @DoranLyong ,

This is a common typo in many papers on computer vision. FLOP in these papers actually means MAC. For example, ResNet-50 actually has 8.2G FLOPs and 4.1G MACs.

The package fvcore also follows this common typo. You can check it by specifying the model in misc/mac_count_with_fvcore.py.

model = timm.models.resnet50()
# or
# from torchvision.models import resnet50
# model = resnet50()

The output of 4.1G actually means MACs.

from poolformer.

yuweihao avatar yuweihao commented on June 19, 2024

Hi @DoranLyong ,

Thanks for your attention.

I used to count the MACs of PoolFormer similar to this code.

However, I found it convenient and accurate enough to use the package fvcore. An example is shown in misc/mac_count_with_fvcore.py. I will update the MAC results measured by fvcore on the arXiv recently.

from poolformer.

DoranLyong avatar DoranLyong commented on June 19, 2024

Thanks for your kind response and code example!

I did check your code and got confused about why you said that FLOPs by fvcore are actually MACs.
I have tried to explore the difference between FLOPs vs. MACs, and found a similar issue.

I understand that FLOP counts both addition and multiplication in separate, but MAC considers both at once.
For example, given ax+b equation, FLOPs are 2(one multiply and one addition), but MAC is 1.

Formally, MACs = $\frac{1}{2}$ $\times$ FLOPs.

When I checked your code in misc directory, I expected there should be division by 2 but there isn't.

Can I ask let me know why FLOP here actually means MAC?

from poolformer.

DoranLyong avatar DoranLyong commented on June 19, 2024

got it! =)

thank you very much! I learned a new thing owing to you.

from poolformer.

yuweihao avatar yuweihao commented on June 19, 2024

You are welcome :)

from poolformer.

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.