Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix divide by 0 error in scheduler #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gato/training/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_linear_warmup_cosine_decay_scheduler(optimizer: Optimizer, num_warmup_st
return LambdaLR(optimizer, lr_lambda, last_epoch)

def _linear_warmup_cosine_decay(current_step: int, *, num_warmup_steps: int,num_training_steps: int, base_lr: float, init_lr: float, min_lr: float, cosine_decay: bool):
if current_step <= num_warmup_steps:
if current_step <= num_warmup_steps and num_warmup_steps != 0:
lr = init_lr + (base_lr - init_lr) * current_step / num_warmup_steps
elif cosine_decay:
# cosine decay from base_lr to min_lr over remaining steps
Expand All @@ -44,4 +44,4 @@ def _linear_warmup_cosine_decay(current_step: int, *, num_warmup_steps: int,num_
for step in current_steps:
lr[step - 1] = _linear_warmup_cosine_decay(step, warmup_steps, max_steps, base_lr, init_lr, min_lr)
plt.plot(current_steps, lr)
plt.show()
plt.show()