Skip to content

Commit

Permalink
chore(core): remove redundant code in EMA (#396)
Browse files Browse the repository at this point in the history
remove redundant code in EMA
  • Loading branch information
Joker316701882 committed Aug 6, 2021
1 parent 61e4b0f commit 97c4b6c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
2 changes: 0 additions & 2 deletions yolox/core/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ def before_epoch(self):
self.save_ckpt(ckpt_name="last_mosaic_epoch")

def after_epoch(self):
if self.use_model_ema:
self.ema_model.update_attr(self.model)

self.save_ckpt(ckpt_name="latest")

Expand Down
13 changes: 0 additions & 13 deletions yolox/utils/ema.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ def is_parallel(model):
return isinstance(model, parallel_type)


def copy_attr(a, b, include=(), exclude=()):
# Copy attributes from b to a, options to only include [...] and to exclude [...]
for k, v in b.__dict__.items():
if (len(include) and k not in include) or k.startswith("_") or k in exclude:
continue
else:
setattr(a, k, v)


class ModelEMA:
"""
Model Exponential Moving Average from https://github.com/rwightman/pytorch-image-models
Expand Down Expand Up @@ -68,7 +59,3 @@ def update(self, model):
if v.dtype.is_floating_point:
v *= d
v += (1.0 - d) * msd[k].detach()

def update_attr(self, model, include=(), exclude=("process_group", "reducer")):
# Update EMA attributes
copy_attr(self.ema, model, include, exclude)

0 comments on commit 97c4b6c

Please sign in to comment.