Download code/zenith/train/schedule.py from Kolgrim/farzenith-small-v1: direct link, hf CLI and curl.
- Browser
- Download file 513 Bytes
-
https://huggingface.co/Kolgrim/farzenith-small-v1/resolve/main/code/zenith/train/schedule.py
- Command line
-
hf download hf://Kolgrim/farzenith-small-v1/code/zenith/train/schedule.py
-
curl -L -o schedule.py https://huggingface.co/Kolgrim/farzenith-small-v1/resolve/main/code/zenith/train/schedule.py
513 Bytes
| """Learning-rate schedule: linear warmup, then cosine decay to a floor.""" | |
| from __future__ import annotations | |
| import math | |
| def lr_at(step: int, peak_lr: float, warmup_steps: int, total_steps: int, min_ratio: float = 0.1) -> float: | |
| if step < warmup_steps: | |
| return peak_lr * (step + 1) / warmup_steps | |
| progress = min(1.0, (step - warmup_steps) / max(1, total_steps - 1 - warmup_steps)) | |
| floor = peak_lr * min_ratio | |
| return floor + (peak_lr - floor) * 0.5 * (1 + math.cos(math.pi * progress)) | |