2017-04-23 59 views
1

Tensorflow cifar10 tutorial,distorted_input函数中,他们通过这样做来设置浮动图像的形状。他们为什么在tensorflow cifar10教程中设置浮点图像的形状?

float_image.set_shape([height, width, 3]) 

,但不是在形状已经伸张时,我们装好了distorted_image

distorted_image = tf.random_crop(reshaped_image, [height, width, 3]) 

为什么我们需要之前,我们把它传递给批处理功能重新设置张量的形状。

回答

0

这是我的意见,为什么它是基于文档完成的。我们先从

distorted_image = tf.random_crop(reshaped_image, [height, width, 3]) 
distorted_image = tf.image.random_flip_left_right(distorted_image) 
distorted_image = tf.image.random_brightness(distorted_image, max_delta=63) 
distorted_image = tf.image.random_contrast(distorted_image, lower=0.2, upper=1.8) 
float_image = tf.image.per_image_standardization(distorted_image) 

random_crop()后,我们知道张的形状,从文档的形状random_flip_left_right()后保持不变。但是文档没有说明形状在random_brightness()random_contrast()之后保留。 (注意之前的函数在返回参数中提到形状保持不变的区别)。

所以据我了解TF并不确切地知道图像的形状之后,我们只是把它提醒到TF与set_shape:

的tf.Tensor.set_shape方法更新的静态形状张量 对象,并且它通常用于在不能直接推断此信息时提供附加形状信息。

相关问题