mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 12:20:11 +01:00
Document what dtype tf.image.resize_images returns.
For consistency, tf.image.resize_images now will always return a float32 when method != ResizeMethod.NEAREST_NEIGHBOR. Before, it returned the same dtype as its input if it could be determined statically that the height and width would not be changed. PiperOrigin-RevId: 171028825
This commit is contained in:
parent
4d70239f0e
commit
9e658545a9
|
|
@ -709,6 +709,12 @@ def resize_images(images,
|
|||
https://en.wikipedia.org/wiki/Bicubic_interpolation)
|
||||
* <b>`ResizeMethod.AREA`</b>: Area interpolation.
|
||||
|
||||
The return value has the same type as `images` if `method` is
|
||||
`ResizeMethod.NEAREST_NEIGHBOR`. It will also have the same type as `images`
|
||||
if the size of `images` can be statically determined to be the same as `size`,
|
||||
because `images` is returned in this case. Otherwise, the return value has
|
||||
type `float32`.
|
||||
|
||||
Args:
|
||||
images: 4-D Tensor of shape `[batch, height, width, channels]` or
|
||||
3-D Tensor of shape `[height, width, channels]`.
|
||||
|
|
|
|||
|
|
@ -1795,6 +1795,21 @@ class ResizeImagesTest(test_util.TensorFlowTestCase):
|
|||
_ = image_ops.resize_images(image, [6, None],
|
||||
image_ops.ResizeMethod.BILINEAR)
|
||||
|
||||
def testReturnDtype(self):
|
||||
target_shapes = [[6, 4], [3, 2], [array_ops.placeholder(dtypes.int32),
|
||||
array_ops.placeholder(dtypes.int32)]]
|
||||
for nptype in self.TYPES:
|
||||
image = array_ops.placeholder(nptype, shape=[1, 6, 4, 1])
|
||||
for opt in self.OPTIONS:
|
||||
for target_shape in target_shapes:
|
||||
y = image_ops.resize_images(image, target_shape, opt)
|
||||
if (opt == image_ops.ResizeMethod.NEAREST_NEIGHBOR or
|
||||
target_shape == image.shape[1:3]):
|
||||
expected_dtype = image.dtype
|
||||
else:
|
||||
expected_dtype = dtypes.float32
|
||||
self.assertEqual(y.dtype, expected_dtype)
|
||||
|
||||
def testSumTensor(self):
|
||||
img_shape = [1, 6, 4, 1]
|
||||
# This test is also conducted with int8, so 127 is the maximum
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user