Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate flops and params #10

Open
Zzhy2000 opened this issue Dec 19, 2024 · 1 comment
Open

How to calculate flops and params #10

Zzhy2000 opened this issue Dec 19, 2024 · 1 comment

Comments

@Zzhy2000
Copy link

Hello, I would like to ask how the flops and params of your model are calculated. Looking forward to your reply.

@mcpaulgeorge
Copy link
Owner

from fvcore.nn import FlopCountAnalysis
model = Walmafa(inp_channels=3,out_channels=3,dim = 16,num_blocks = [2,3,4],heads = [1,2,4,8],ffn_expansion_factor = 2.66,bias = False,LayerNorm_type = 'WithBias',attention=True,skip = False)
model = model.cuda("cuda:2")
input_example = torch.randn(1, 3, 256, 256).cuda("cuda:2")
flops = FlopCountAnalysis(model,(input_example))
print(f'GMac:{flops.total()/(102410241024)}')

In terms of params, you can find the calculated code in train.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants