Skip to content

Instantly share code, notes, and snippets.

@jaems33
Last active November 2, 2018 17:19
Show Gist options
  • Save jaems33/264888c0eaaf63f48700dd268b2d65a3 to your computer and use it in GitHub Desktop.
Save jaems33/264888c0eaaf63f48700dd268b2d65a3 to your computer and use it in GitHub Desktop.
From train.py via fast.ai
def fit_one_cycle(learn:Learner,
cyc_len:int,
max_lr:Union[Floats,slice]=default_lr,
moms:Tuple[float,float]=(0.95,0.85),
div_factor:float=25.,
pct_start:float=0.3,
wd:float=None,
callbacks:Optional[CallbackList]=None, **kwargs) -> None:
"""Fit a model following the 1cycle policy."""
max_lr = learn.lr_range(max_lr)
callbacks = ifnone(callbacks, [])
callbacks.append(OneCycleScheduler(learn,
max_lr,
moms=moms,
div_factor=div_factor,
pct_start=pct_start, **kwargs))
learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment