yolov5 icon indicating copy to clipboard operation
yolov5 copied to clipboard

EMA has actually done nothing

Open cissoidx opened this issue 2 years ago • 3 comments

Search before asking

  • [X] I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

Hello,

EMA is to collect the moving average of the real model with the decay factor ramping from 0 to 0.9999. However, in the code, the ema is neither helping to improve validation nor training. Every batch, the ema.update is called, the ema model updates itself using a decay factor to mixup with the real model, and saves the resulting weights in itself. And every epoch, the ema.update_attr is called, the real model gets copied to the ema model, and the accumulated ema weights are overwritten. So every time before validation and model saving, the ema has actually the real model weights in it. It is as if the ema weights never existed. I think that this is a bug, can we please just remove ema out of the code or fix it somehow?

Thanks,

cissoidx avatar Aug 16 '22 06:08 cissoidx

@glenn-jocher Can you please check if this is true? and is there a way to fix it?

cissoidx avatar Aug 17 '22 02:08 cissoidx

@cissoidx EMA works correctly, there is no bug. Model weights are not attributes.

You can disable EMA by setting decay factor to 0.0.

glenn-jocher avatar Aug 17 '22 23:08 glenn-jocher

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

  • Wiki – https://github.com/ultralytics/yolov5/wiki
  • Tutorials – https://docs.ultralytics.com/yolov5
  • Docs – https://docs.ultralytics.com

Access additional Ultralytics ⚡ resources:

  • Ultralytics HUB – https://ultralytics.com/hub
  • Vision API – https://ultralytics.com/yolov5
  • About Us – https://ultralytics.com/about
  • Join Our Team – https://ultralytics.com/work
  • Contact Us – https://ultralytics.com/contact

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

github-actions[bot] avatar Sep 17 '22 00:09 github-actions[bot]