Commit 79e2d13
Fix: Correct YOLO loss gradient for x,y coordinates (#3088)
* Fix: Correct YOLO loss gradient for x,y coordinates
The gradient calculation for bounding box x and y coordinates in the
`loss_yolo_` helper `impl::yolo_helper_impl::tensor_to_loss` was
missing a factor of 2.0. This factor arises from the chain rule
due to the coordinate transformation `output_scaled = network_output * 2.0 - 0.5`,
where the loss is calculated based on `output_scaled`, but the gradient
needs to be with respect to `network_output`.
This commit multiplies the affected gradient terms by 2.0f to correctly
apply the chain rule.
* scale the loss
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 81cd1f1 commit 79e2d13
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3827 | 3827 | | |
3828 | 3828 | | |
3829 | 3829 | | |
3830 | | - | |
3831 | | - | |
| 3830 | + | |
| 3831 | + | |
3832 | 3832 | | |
3833 | 3833 | | |
3834 | 3834 | | |
| |||
3863 | 3863 | | |
3864 | 3864 | | |
3865 | 3865 | | |
3866 | | - | |
| 3866 | + | |
3867 | 3867 | | |
3868 | 3868 | | |
3869 | 3869 | | |
| |||
0 commit comments