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 can I get the transformers' parameters? #1479

Closed
YongtaoGe opened this issue Oct 10, 2019 · 2 comments
Closed

How can I get the transformers' parameters? #1479

YongtaoGe opened this issue Oct 10, 2019 · 2 comments

Comments

@YongtaoGe
Copy link

❓ Questions & Help

Hi, I am new to transformers. Does this library offer an interface to compute the total number of different model's parameters?

@LysandreJik
Copy link
Member

The models we use inherit directly from torch.nn.Module for our pytorch models and tf.keras.layers.Layer for tensorflow modules. You can therefore get the total number of parameters as you would do with any other pytorch/tensorflow modules:

sum(p.numel() for p in model.parameters() if p.requires_grad) for pytorch and
np.sum([np.prod(v.shape) for v in tf.trainable_variables]) for tensorflow, for example.

@YongtaoGe
Copy link
Author

Got it!

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