Change keras.layers.Upsampling2D to use new image resizing function (resize_images_v2). The old resizing function has various bugs (for instance, it was not reflection or translation invariant).

Fixes #29856.

PiperOrigin-RevId: 255296104
This commit is contained in:
Martin Wicke 2019-06-26 17:13:12 -07:00 committed by TensorFlower Gardener
parent bb2a1d3ee8
commit 15f6c30d79
2 changed files with 5 additions and 3 deletions

View File

@ -2610,9 +2610,11 @@ def resize_images(x, height_factor, width_factor, data_format,
if data_format == 'channels_first':
x = permute_dimensions(x, [0, 2, 3, 1])
if interpolation == 'nearest':
x = image_ops.resize_nearest_neighbor(x, new_shape)
x = image_ops.resize_images_v2(
x, new_shape, method=image_ops.ResizeMethod.NEAREST_NEIGHBOR)
elif interpolation == 'bilinear':
x = image_ops.resize_bilinear(x, new_shape)
x = image_ops.resize_images_v2(x, new_shape,
method=image_ops.ResizeMethod.BILINEAR)
else:
raise ValueError('interpolation should be one '
'of "nearest" or "bilinear".')