RandomTranslation
類別keras.layers.RandomTranslation(
height_factor,
width_factor,
fill_mode="reflect",
interpolation="bilinear",
seed=None,
fill_value=0.0,
data_format=None,
**kwargs
)
一個在訓練期間隨機平移影像的預處理層。
此層將在訓練期間對每個影像應用隨機平移,並根據 fill_mode
填充空白區域。
輸入像素值可以是任何範圍(例如 [0., 1.)
或 [0, 255]
),並且可以是整數或浮點 dtype。預設情況下,此層將輸出浮點數。
輸入形狀
3D(非批次處理)或 4D(批次處理)張量,形狀為:(..., height, width, channels)
(在 "channels_last"
格式中),或 (..., channels, height, width)
(在 "channels_first"
格式中)。
輸出形狀
3D(非批次處理)或 4D(批次處理)張量,形狀為:(..., target_height, target_width, channels)
,或 (..., channels, target_height, target_width)
(在 "channels_first"
格式中)。
注意: 此層可以安全地在 tf.data
管道內使用(與您使用的後端無關)。
引數
height_factor=(-0.2, 0.3)
會導致輸出在 [-20%, +30%]
範圍內隨機平移。height_factor=0.2
會導致輸出高度在 [-20%, +20%]
範圍內隨機平移。width_factor=(-0.2, 0.3)
會導致輸出向左平移 20%,向右平移 30%。width_factor=0.2
會導致輸出高度向左或向右平移 20%。"constant"
、"nearest"
、"wrap"
和 "reflect"
。預設為 "constant"
。"reflect"
:(d c b a | a b c d | d c b a)
輸入通過在最後一個像素的邊緣反射來擴展。"constant"
:(k k k k | a b c d | k k k k)
輸入通過用 fill_value
指定的相同常數值 k 填充邊緣之外的所有值來擴展。"wrap"
:(a b c d | a b c d | a b c d)
輸入通過環繞到對邊緣來擴展。"nearest"
:(a a a a | a b c d | d d d d)
輸入通過最近的像素來擴展。請注意,當使用 torch 後端時,"reflect"
會重定向到 "mirror"
(c d c b | a b c d | c b a b)
,因為 torch 不支援 "reflect"
。請注意,torch 後端不支援 "wrap"
。"nearest"
、"bilinear"
。fill_mode="constant"
時要填充在邊界之外的值。"channels_last"
或 "channels_first"
。輸入中維度的順序。"channels_last"
對應於形狀為 (batch, height, width, channels)
的輸入,而 "channels_first"
對應於形狀為 (batch, channels, height, width)
的輸入。它預設為在您的 Keras 設定檔 ~/.keras/keras.json
中找到的 image_data_format
值。如果您從未設定它,則它將為 "channels_last"
。name
和 dtype
。