初学Tensorflow,望见谅,最近在学习数据増广,发现在进行图像大小随机缩放时会出错,代码如下:
img = tf.placeholder(tf.uint8,shape=[2048,1024,3])
#随机获取Scale
scale = tf.random_uniform([1], minval=0.5, maxval=2.0, dtype=tf.float32, seed=None)
#求resize后的图像大小
h_new = tf.to_int32(tf.multiply(tf.to_float(tf.shape(img)[0]), scale))
w_new = tf.to_int32(tf.multiply(tf.to_float(tf.shape(img)[1]), scale))
#进行resize
new_shape = tf.squeeze(tf.stack([h_new, w_new]), squeeze_dims=[1])
img = tf.image.resize_images(img, size=new_shape)
但是我发现,resize以后的img的高和宽竟然是none
另外,如果写成如下,也不行
但是如果将resize的大小限定死,是可以的,这和网上大部分网页上是一致的
所以问问各位大神,这是为什么啊,为什么不能随机resize一张图啊。