Download pair_alignment/utils/build_optimizer.py from latticetower/nested-tkf-repro-workspace: direct link, hf CLI and curl.
- Browser
- Download file 926 Bytes
-
https://huggingface.co/datasets/latticetower/nested-tkf-repro-workspace/resolve/main/pair_alignment/utils/build_optimizer.py
- Command line
-
hf download hf://datasets/latticetower/nested-tkf-repro-workspace/pair_alignment/utils/build_optimizer.py
-
curl -L -o build_optimizer.py https://huggingface.co/datasets/latticetower/nested-tkf-repro-workspace/resolve/main/pair_alignment/utils/build_optimizer.py
926 Bytes
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Wed Jan 29 19:27:33 2025 | |
| """ | |
| import optax | |
| import numpy as np | |
| def build_optimizer(args): | |
| config = args.optimizer_config | |
| learning_rate = optax.warmup_cosine_decay_schedule(init_value= config['init_value'], | |
| peak_value= config['peak_value'], | |
| end_value = config['end_value'], | |
| warmup_steps= config['warmup_steps'], | |
| decay_steps= args.num_epochs) | |
| base_optimizer = optax.adamw(learning_rate = learning_rate, | |
| weight_decay = config['weight_decay']) | |
| tx = optax.MultiSteps(opt = base_optimizer, | |
| every_k_schedule = config['every_k_schedule']) | |
| return tx | |