Created
October 19, 2022 01:02
-
-
Save 1pha/577206868960cb4ca3146e737dd7a319 to your computer and use it in GitHub Desktop.
Count Pytorch Model Parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference | |
# https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325/8 | |
def count_parameters(model): | |
return sum(p.numel() for p in model.parameters() if p.requires_grad) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment