Download fireredasr/utils/param.py from AXERA-TECH/FireRedASR-AED: direct link, hf CLI and curl.
- Browser
- Download file 411 Bytes
-
https://huggingface.co/AXERA-TECH/FireRedASR-AED/resolve/main/fireredasr/utils/param.py
- Command line
-
hf download hf://AXERA-TECH/FireRedASR-AED/fireredasr/utils/param.py
-
curl -L -o param.py https://huggingface.co/AXERA-TECH/FireRedASR-AED/resolve/main/fireredasr/utils/param.py
411 Bytes
| import logging | |
| import torch | |
| def count_model_parameters(model): | |
| if not isinstance(model, torch.nn.Module): | |
| return 0, 0 | |
| name = f"{model.__class__.__name__} {model.__class__}" | |
| num = sum(p.numel() for p in model.parameters() if p.requires_grad) | |
| size = num * 4.0 / 1024.0 / 1024.0 # float32, MB | |
| logging.info(f"#param of {name} is {num} = {size:.1f} MB (float32)") | |
| return num, size | |