Spaces:
Running on Zero
Running on Zero
Download utils/model_utils.py from yunusserhat/Location_Predictor: direct link, hf CLI and curl.
- Browser
- Download file 545 Bytes
-
https://huggingface.co/spaces/yunusserhat/Location_Predictor/resolve/main/utils/model_utils.py
- Command line
-
hf download hf://spaces/yunusserhat/Location_Predictor/utils/model_utils.py
-
curl -L -o model_utils.py https://huggingface.co/spaces/yunusserhat/Location_Predictor/resolve/main/utils/model_utils.py
545 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}" | |
| ) | |