Skip to content

Commit

Permalink
zero-mAP fix 3 (ultralytics#9058)
Browse files Browse the repository at this point in the history
* zero-mAP fix 3

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update torch_utils.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update torch_utils.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and Clay Januhowski committed Sep 8, 2022
1 parent 05de881 commit 4899f92
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ def __init__(self, model, decay=0.9999, tau=2000, updates=0):
for p in self.ema.parameters():
p.requires_grad_(False)

@smart_inference_mode()
def update(self, model):
# Update EMA parameters
self.updates += 1
Expand All @@ -423,7 +422,7 @@ def update(self, model):
if v.dtype.is_floating_point: # true for FP16 and FP32
v *= d
v += (1 - d) * msd[k].detach()
assert v.dtype == msd[k].dtype == torch.float32, f'EMA {v.dtype} and model {msd[k]} must be updated in FP32'
assert v.dtype == msd[k].detach().dtype == torch.float32, f'EMA {v.dtype} and model {msd[k]} must both be FP32'

def update_attr(self, model, include=(), exclude=('process_group', 'reducer')):
# Update EMA attributes
Expand Down

0 comments on commit 4899f92

Please sign in to comment.