2017-04-07 113 views
2

我想在我的張量流模型中從輸入圖像中提取圖像補丁。 假設輸入圖像是[batch, in_width, in_height, channels],我想輸出[no_patches, patch_width, patch_height, channels]no_patches是可以從input_image中提取補丁的總數。如何設置tf.extract_image_patches的參數

我發現tf.extract_image_patches可以完成這項工作。 但是,我不明白參數stridesrates的區別。

有人可以解釋如何使用上述功能來完成這項工作嗎?

回答

0

strides是關於數據窗口的移動。

rates是關於如何「鋪開」窗口。

例如,如果您使用strides = [1,5,5,1],則第1維和第2維都會跳出5個像素的窗口。如果你使用rates = [1,1,1,1]你的窗口是'緊湊的',這意味着所有的像素都是連續的。如果你使用rates = [1,1,2,1],那麼你的窗口在第二維度展開,並採取了每個像素與ksizes = [1,3,2,1] 2.

例(忽略的進步現在):在我們使用左,rates = [1,1,1,1],在我們使用rates = [1,1,2,1]中間,在右邊我們用rates = [1,2,2,1]

* * 3 4 5   * 2 * 4 5   * 2 * 4 5 
* * 8 9 10   * 7 * 9 10   6 7 8 9 10 
* * 13 14 15   * 12 * 14 15   * 12 * 14 15 
16 17 18 19 20   16 17 18 19 20   16 17 18 19 20 
21 22 23 24 25   21 22 23 24 25   * 22 * 24 25