Skip to content

Commit

Permalink
fix to work linear/cosine scheduler closes kohya-ss#1651 ref kohya-ss…
Browse files Browse the repository at this point in the history
  • Loading branch information
kohya-ss committed Sep 29, 2024
1 parent 1567549 commit 012e7e6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4496,6 +4496,15 @@ def wrap_check_needless_num_warmup_steps(return_vals):
**lr_scheduler_kwargs,
)

# these schedulers do not require `num_decay_steps`
if name == SchedulerType.LINEAR or name == SchedulerType.COSINE:
return schedule_func(
optimizer,
num_warmup_steps=num_warmup_steps,
num_training_steps=num_training_steps,
**lr_scheduler_kwargs,
)

# All other schedulers require `num_decay_steps`
if num_decay_steps is None:
raise ValueError(f"{name} requires `num_decay_steps`, please provide that argument.")
Expand Down

0 comments on commit 012e7e6

Please sign in to comment.