File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -209,13 +209,14 @@ def _get_lr_outer(
209
209
* ,
210
210
num_warmup_steps : int ,
211
211
num_training_steps : int ,
212
+ num_cycles : float ,
212
213
min_lr_rate : float = 0.0 ,
213
214
):
214
215
if current_step < num_warmup_steps :
215
216
return 1
216
217
217
218
progress = float (current_step - num_warmup_steps ) / float (max (1 , num_training_steps - num_warmup_steps ))
218
- factor = 0.5 * (1.0 + math .cos (math .pi * 2.0 * progress ))
219
+ factor = 0.5 * (1.0 + math .cos (math .pi * float ( num_cycles ) * 2.0 * progress ))
219
220
factor = factor * (1 - min_lr_rate ) + min_lr_rate
220
221
return max (0 , factor )
221
222
@@ -226,6 +227,7 @@ def get_lr_outer(optimizer, config: Config):
226
227
num_warmup_steps = config .warmup_steps ,
227
228
# num_training_steps=config.total_steps,
228
229
num_training_steps = config .total_steps / 4 ,
230
+ num_cycles = 0.5 ,
229
231
)
230
232
return LambdaLR (optimizer , lambda_lr , - 1 )
231
233
You can’t perform that action at this time.
0 commit comments