Download utils/model_utils.py from procgne/Plonk: direct link, hf CLI and curl.
- Browser
- Download file 531 Bytes
-
https://huggingface.co/spaces/procgne/Plonk/resolve/main/utils/model_utils.py
- Command line
-
hf download hf://spaces/procgne/Plonk/utils/model_utils.py
-
curl -L -o model_utils.py https://huggingface.co/spaces/procgne/Plonk/resolve/main/utils/model_utils.py
531 Bytes
| def print_trainable_parameters(model): | |
| """ | |
| Prints the number and percentage of trainable parameters in the model. | |
| Useful for tracking % parameters trained for LoRA. | |
| """ | |
| trainable_params = 0 | |
| all_param = 0 | |
| for _, param in model.named_parameters(): | |
| all_param += param.numel() | |
| if param.requires_grad: | |
| trainable_params += param.numel() | |
| print( | |
| f"trainable params: {trainable_params} || all params: {all_param} || trainable%: {100 * trainable_params / all_param}" | |
| ) | |