MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / get_constant_schedule

Function get_constant_schedule

src/diffusers/optimization.py:40–53  ·  view source on GitHub ↗

Create a schedule with a constant learning rate, using the learning rate set in optimizer. Args: optimizer ([`~torch.optim.Optimizer`]): The optimizer for which to schedule the learning rate. last_epoch (`int`, *optional*, defaults to -1): The index

(optimizer: Optimizer, last_epoch: int = -1)

Source from the content-addressed store, hash-verified

38
39
40def get_constant_schedule(optimizer: Optimizer, last_epoch: int = -1) -> LambdaLR:
41 """
42 Create a schedule with a constant learning rate, using the learning rate set in optimizer.
43
44 Args:
45 optimizer ([`~torch.optim.Optimizer`]):
46 The optimizer for which to schedule the learning rate.
47 last_epoch (`int`, *optional*, defaults to -1):
48 The index of the last epoch when resuming training.
49
50 Return:
51 `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
52 """
53 return LambdaLR(optimizer, lambda _: 1, last_epoch=last_epoch)
54
55
56def get_constant_schedule_with_warmup(optimizer: Optimizer, num_warmup_steps: int, last_epoch: int = -1) -> LambdaLR:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected