zero-mAP fix return `.detach()` to EMA (#9056)

Resolves https://github.com/ultralytics/hub/issues/82

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

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/9058/head
Glenn Jocher 2022-08-21 02:23:39 +02:00 committed by GitHub
parent 93f63ee33f
commit 841f312f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -422,7 +422,7 @@ class ModelEMA:
for k, v in self.ema.state_dict().items():
if v.dtype.is_floating_point: # true for FP16 and FP32
v *= d
v += (1 - d) * msd[k]
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'
def update_attr(self, model, include=(), exclude=('process_group', 'reducer')):