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

The Total params: and Params size (MB) of the model printed by summary are different from the bit_base model in timm library. Theoretically, the same settings should be the same. What is the reason? #329

Open
lucker26 opened this issue Sep 26, 2024 · 1 comment

Comments

@lucker26
Copy link

import torch
from vit import ViT
from torchsummary import summary
import timm
v = ViT(
image_size = 224,
patch_size = 16,
num_classes = 1000,
dim = 768,
depth = 12,
heads = 12,
mlp_dim = 3072,
dropout = 0.1,
emb_dropout = 0.1
)

使用 summary 显示模型的摘要

summary(v, input_size=(3, 224, 224), device='cpu') # 传入输入的形状 (C, H, W)

加载 ViT-B/16 模型

model = timm.create_model('vit_base_patch16_224', pretrained=False)

打印模型的摘要信息

summary(model, input_size=( 3, 224, 224))

@lucker26 lucker26 changed the title 通过summary打印出模型的Total params:和Params size (MB)与timm库中的bit_base模型不一样,理论上相同的设置应该是一样,这是什么原因呢? The Total params: and Params size (MB) of the model printed by summary are different from the bit_base model in timm library. Theoretically, the same settings should be the same. What is the reason? Sep 26, 2024
@lucker26
Copy link
Author

image
The result of the first diagram is the model you wrote. The result of the second graph is timm's.
image

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

1 participant