Skip to content

Commit aee71b4

Browse files
committed
Document the warmup scheduler
1 parent ca93780 commit aee71b4

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

speechbrain/lobes/models/transformer/Conformer.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,21 @@ def forward(
11621162

11631163

11641164
class ConformerWarmupScheduler:
1165+
"""Scheduler for a Conformer warmup. Linearly increases the warmup from the
1166+
`warmup_start` to the `warmup_end` depending on the current step count.
1167+
See :meth:`~ConformerEncoder.forward` for how this value is used.
1168+
1169+
Arguments
1170+
---------
1171+
step_count : int
1172+
After how many optimizer steps should the warmup reach the `warmup_end`
1173+
value.
1174+
warmup_start : float
1175+
The warmup value at the start of training.
1176+
warmup_end : float
1177+
The warmup value reached at the end of the warmup period.
1178+
"""
1179+
11651180
def __init__(
11661181
self,
11671182
step_count: int = 3000,
@@ -1172,7 +1187,21 @@ def __init__(
11721187
self.warmup_start = warmup_start
11731188
self.warmup_end = warmup_end
11741189

1175-
def __call__(self, current_step):
1190+
def __call__(self, current_step: int) -> float:
1191+
"""Compute the current warmup value depending on the current optimizer
1192+
step count.
1193+
1194+
Arguments
1195+
---------
1196+
current_step : int
1197+
The current optimizer step (not epoch).
1198+
1199+
Returns
1200+
-------
1201+
float
1202+
Warmup value to apply, linearly interpolated between `warmup_start`
1203+
and `warmup_end`.
1204+
"""
11761205
warmup_completion = min(1.0, current_step / self.step_count)
11771206

11781207
# lerp from warmup_start to warmup_end

0 commit comments

Comments
 (0)