Download FlashVTG/utils/model_utils.py from zhaoshiwen/flashvtg-experiment-backup: direct link, hf CLI and curl.
- Browser
- Download file 583 Bytes
-
https://huggingface.co/datasets/zhaoshiwen/flashvtg-experiment-backup/resolve/main/FlashVTG/utils/model_utils.py
- Command line
-
hf download hf://datasets/zhaoshiwen/flashvtg-experiment-backup/FlashVTG/utils/model_utils.py
-
curl -L -o model_utils.py https://huggingface.co/datasets/zhaoshiwen/flashvtg-experiment-backup/resolve/main/FlashVTG/utils/model_utils.py
583 Bytes
| def count_parameters(model, verbose=True): | |
| """Count number of parameters in PyTorch model, | |
| References: https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325/7. | |
| from utils.utils import count_parameters | |
| count_parameters(model) | |
| import sys | |
| sys.exit(1) | |
| """ | |
| n_all = sum(p.numel() for p in model.parameters()) | |
| n_trainable = sum(p.numel() for p in model.parameters() if p.requires_grad) | |
| if verbose: | |
| print("Parameter Count: all {:,d}; trainable {:,d}".format(n_all, n_trainable)) | |
| return n_all, n_trainable | |