You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tf.image.resize gradients fail for half/bfloat16/float64 with antialias or lanczos/gaussian/mitchellcubic, and are silently None for bicubic half/bfloat16 #129737
Backprop through tf.image.resize is broken for half and bfloat16 images in two ways, which makes mixed precision training fail for models that resize inside the graph:
With antialias=True, or method = lanczos3/lanczos5/gaussian/mitchellcubic, the gradient raises InvalidArgumentError for any dtype other than float32 (float64 too). Those go through ScaleAndTranslate, which accepts half/bfloat16/double images, but ScaleAndTranslateGrad is declared T: {float} for both grads and original_image and only has a float32 kernel. The registered gradient (image_grad.py#L143-L150) passes the original image through as is, so the grad op rejects it. The kernel only reads the image's shape.
With method="bicubic" (no antialias), the gradient for half/bfloat16 images is silently None. _ResizeBicubicGrad (image_grad.py#L164-L172) only computes it for float32/float64 because ResizeBicubicGrad has no 16-bit kernel. No error is raised, so the layers before the resize just stop training.
bilinear and nearest without antialias already return gradients in the input dtype for half, bfloat16 and float64, so these two look like gaps rather than intended restrictions.
Expected: gradients in the input's dtype, like ResizeBilinearGrad returns.
float32 | antialias: float32 | bicubic: float32
float16 | antialias: error: cannot compute ScaleAndTranslateGrad as input #1(zero-based) was expected to be a float tensor but is a half tensor [Op:ScaleAndTranslateGrad] name: | bicubic: None
bfloat16 | antialias: error: cannot compute ScaleAndTranslateGrad as input #1(zero-based) was expected to be a float tensor but is a bfloat16 tensor [Op:ScaleAndTranslateGrad] name: | bicubic: None
float64 | antialias: error: cannot compute ScaleAndTranslateGrad as input #1(zero-based) was expected to be a float tensor but is a double tensor [Op:ScaleAndTranslateGrad] name: | bicubic: float64
Hi @bodapatisaikrishna ,
Thank you for reporting this issue and raising the PR to address it. A fix has been proposed in PR, and the issue will be resolved once it is merged.
We truly appreciate your initiative and effort in contributing this fix.
Activity
Venkat6871 commentedon Nov 2, 2026
Hi @bodapatisaikrishna ,
Thank you for reporting this issue and raising the PR to address it. A fix has been proposed in PR, and the issue will be resolved once it is merged.
We truly appreciate your initiative and effort in contributing this fix.
google-ml-butler commentedon Nov 2, 2026
Are you satisfied with the resolution of your issue?
Yes
No
Support half and bfloat16 images in resize gradients