Add warmup and accumulation (#52)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ayush Chaurasia
2022-11-25 00:42:16 +05:30
committed by GitHub
parent 298287298d
commit d7df1770fa
3 changed files with 44 additions and 4 deletions

View File

@ -27,6 +27,7 @@ single_cls: False # train multi-class data as single-class
image_weights: False # use weighted image selection for training
shuffle: True
rect: False # support rectangular training
cos_lr: False # Use cosine LR scheduler
overlap_mask: True # Segmentation masks overlap
mask_ratio: 4 # Segmentation mask downsample ratio
@ -71,6 +72,7 @@ mosaic: 1.0 # image mosaic (probability)
mixup: 0.0 # image mixup (probability)
copy_paste: 0.0 # segment copy-paste (probability)
label_smoothing: 0.0
nbs: 64 # nominal batch size
# anchors: 3
# Hydra configs --------------------------------------------------------------------------------------------------------

View File

@ -194,6 +194,11 @@ def de_parallel(model):
return model.module if is_parallel(model) else model
def one_cycle(y1=0.0, y2=1.0, steps=100):
# lambda function for sinusoidal ramp from y1 to y2 https://arxiv.org/pdf/1812.01187.pdf
return lambda x: ((1 - math.cos(x * math.pi / steps)) / 2) * (y2 - y1) + y1
class ModelEMA:
""" Updated Exponential Moving Average (EMA) from https://github.com/rwightman/pytorch-image-models
Keeps a moving average of everything in the model state_dict (parameters and buffers)