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 get obtain the size (MB) of the BERT #3

Closed
xwuShirley opened this issue Apr 21, 2022 · 1 comment
Closed

How to get obtain the size (MB) of the BERT #3

xwuShirley opened this issue Apr 21, 2022 · 1 comment

Comments

@xwuShirley
Copy link

xwuShirley commented Apr 21, 2022

image

Dear authors,

Great thanks for the opensource code. I wonder how you calculate the size of the models?
Actually, I have a very fundamental question the BERT-base model (fp32) is
embedding_param = 23835648
num_param = 85526016
(embedding_param + num_param) / 1e6 * 4 =437.4MB

instead of 418MB?

for n, p in model.items():
    if 'Norm' in n:
        continue
    if len(p.size()) ==2 :
        if 'embedding' in n:
            embedding_param += p.numel()
        else:
            num_param += p.numel()

It would be great if you can clarify this. (similar repohttps://github.com/huawei-noah/Pretrained-Language-Model/issues/184)

@xwuShirley
Copy link
Author

found the error should be (embedding_param + num_param) / (1024*1024) * 4 =437.4MB

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