2017-04-23 41 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方法更新的靜態形狀張量 對象,並且它通常用於在不能直接推斷此信息時提供附加形狀信息。

相關問題