HyperImageAugment
classkeras_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
)
A image augmentation hypermodel.
The HyperImageAugment
class searches for the best combination of image
augmentation operations in Keras preprocessing layers. The input shape of
the model should be (height, width, channels). The output of the model is
of the same shape as the input.
Arguments
(256, 256, 3)
.layers.Input()
)
to use as image input for the model.rotate
is a single number, the search range
is [0, rotate
].
The transform is off when set to None.translate_x
is a single number, the search
range is [0, translate_x
].
The transform is off when set to None.translate_y
is a single number ,the search
range is [0, translate_y
]. The transform is off when set to None.contrast
is a single number, the
search rnage is [0, contrast
].
The transform is off when set to None.augment_layers
is 0, all transform are applied sequentially.
When augment_layers
is nonzero, or a list of two ints, a simple
version of RandAugment(https://arxiv.org/abs/1909.13719) is used.
A search space for 'augment_layers' is created to search [0,
augment_layers
], or between the two ints if a augment_layers
is
a list. For each trial, the hyperparameter 'augment_layers'
determines number of layers of augment transforms are applied,
each randomly picked from all available transform types with equal
probability on each sample.keras_tuner.HyperModel
.Example
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)
Then the hypermodel hm_aug
will search 'factor_rotate' between [0.2, 0.3]
and 'factor_translate_x' between [0, 0.1]. These two augments are applied
on all samples with factor picked per each trial.
hm_aug = HyperImageAugment(input_shape=(32, 32, 3),
translate_x=0.5,
translate_y=[0.2, 0.4]
contrast=None)
Then the hypermodel hm_aug
will search 'factor_rotate' between [0, 0.2],
'factor_translate_x' between [0, 0.5], 'factor_translate_y' between
[0.2, 0.4]. It will use RandAugment, searching 'augment_layers'
between [0, 3]. Each layer on each sample will be chosen from rotate,
translate_x and translate_y.