HyperImageAugment
類別keras_tuner.applications.HyperImageAugment(
input_shape=None,
input_tensor=None,
rotate=0.5,
translate_x=0.4,
translate_y=0.4,
contrast=0.3,
augment_layers=3,
**kwargs
)
一個影像增強超模型。
HyperImageAugment
類別會在 Keras 預處理層中搜尋影像增強操作的最佳組合。模型的輸入形狀應為(高度、寬度、通道數)。模型的輸出形狀與輸入形狀相同。
參數
(256, 256, 3)
。layers.Input()
的輸出),用作模型的影像輸入。rotate
為單一數字時,搜尋範圍為 [0, rotate
]。當設定為 None 時,變換會關閉。translate_x
為單一數字時,搜尋範圍為 [0, translate_x
]。當設定為 None 時,變換會關閉。translate_y
為單一數字時,搜尋範圍為 [0, translate_y
]。如果設為 None,則會關閉轉換。contrast
為單一數字時,搜尋範圍為 [0, contrast
]。如果設為 None,則會關閉轉換。augment_layers
為 0 時,所有轉換都會依序套用。當 augment_layers
為非零值或兩個整數的清單時,將使用 RandAugment(https://arxiv.org/abs/1909.13719) 的簡化版本。系統會建立「augment_layers」的搜尋空間,以便在 [0, augment_layers
] 之間或兩個整數之間搜尋 (如果 augment_layers
為清單)。對於每個試驗,超參數「augment_layers」會決定套用擴增轉換的層數,並從所有可用的轉換類型中隨機挑選每一層,每個樣本的機率均等。keras_tuner.HyperModel
。範例
hm_aug = HyperImageAugment(input_shape=(32, 32, 3),
augment_layers=0,
rotate=[0.2, 0.3],
translate_x=0.1,
translate_y=None,
contrast=None)
然後,超模型 hm_aug
會在 [0.2, 0.3] 之間搜尋「factor_rotate」,並在 [0, 0.1] 之間搜尋「factor_translate_x」。這兩個擴增會套用至所有樣本,並為每個試驗挑選因子。
hm_aug = HyperImageAugment(input_shape=(32, 32, 3),
translate_x=0.5,
translate_y=[0.2, 0.4]
contrast=None)
然後,超模型 hm_aug
會在 [0, 0.2] 之間搜尋「factor_rotate」,在 [0, 0.5] 之間搜尋「factor_translate_x」,並在 [0.2, 0.4] 之間搜尋「factor_translate_y」。它會使用 RandAugment,並在 [0, 3] 之間搜尋「augment_layers」。每個樣本上的每一層都會從旋轉、translate_x 和 translate_y 中選出。