深度学习是基于数据驱动的学科,通过data augmentation(数据扩张)可以有效的进行数据扩张并进行一些数据normalized操作. 以此,便于扩大数据集,丰富数据多样性,便于学习到更深度广泛的特征, 避免模型的overfit和underfit.
这里直接调用keras.preprocessing.image中的ImageDataGenerator. 这个函数包含了常用的图像变换和normalization方法.
- 函数介绍
from keras.preprocessing.image import ImageDataGenerator
? ImageDataGenerator # 查看函数帮助
- 函数参数列表(带默认值)如下:
- featurewise_center=False:
设置输入特征的均值为0(每一个维度,feature-wise)
Set input mean to 0 over the dataset, feature-wise. - samplewise_center=False:
设置每一个样本的均值为0.(样本级别的均值, 也就是该样本所有特征之和的平均为0)
Set each sample mean to 0. - featurewise_std_normalization=False
每一个特征维度除以该维度的标准差.
Divide inputs by std of the dataset, feature-wise. - samplewise_std_normalization=False
每一个特征(所有维度)整体除以相应的标准差.
Divide each input by its std. - zca_whitening=False
采用ZCA白化操作.
Apply ZCA(Zero-phase Component Analysis) whitening - zca_epsilon=1e-06
epsilon值
epsilon for ZCA whitening. Default is 1e-6. - rotation_range=0.0
随机旋转的最大值.?
Degree range for random rotations. - width_shift_range=0.0
水平平移的比例范围(范围的最大值)
Float (fraction of total width). Range for random horizontal shifts. - height_shift_range=0.0
纵向平移的比例返回(范围的最大值)
Float (fraction of total height). Range for random vertical shifts. - brightness_range=None
- shear_range=0.0
裁剪强度范围最大值(逆时针方向角度)
Shear Intensity (Shear angle in counter-clockwise direction in degrees) - zoom_range=0.0
随机缩放范围(到底zoom in/out)
Float or [lower, upper]. Range for random zoom. If a float,[lower, upper] = [1-zoom_range, 1+zoom_range]
. - channel_shift_range=0.0
Range for random channel shifts. - fill_mode='nearest'
One of {"constant", "nearest", "reflect" or "wrap"}. Default is 'nearest'.
Points outside the boundaries of the input are filled according to the given mode:
'constant': kkkkkkkk|abcd|kkkkkkkk (cval=k)
'nearest': aaaaaaaa|abcd|dddddddd
'reflect': abcddcba|abcd|dcbaabcd
'wrap': abcdabcd|abcd|abcdabcd - cval=0.0
Value used for points outside the boundaries whenfill_mode = "constant"
. - horizontal_flip=False
Randomly flip inputs horizontally. (难道不是=True, 就一定翻转?), 如果是随机翻转, 则说明,选择该项之后, 在训练过程中随机对图片执行该操作, 而不是一定执行. 如果一定执行,那么训练集的数量就会增加., 应该是随机翻转. - vertical_flip=False
Randomly flip inputs vertically. - rescale=None
Defaults to None. If None or 0, no rescaling is applied,otherwise we multiply the data by the value provided (before applying any other transformation). - preprocessing_function=None
function that will be implied on each input. The function will run after the image is resized and augmented. The function should take one argument: one image (Numpy tensor with rank 3), and should output a Numpy tensor with the same shape. - data_format=None
One of {"channels_first", "channels_last"}.
"channels_last" mode means that the images should have shape(samples, height, width, channels)
,
"channels_first" mode means that the images should have shape(samples, channels, height, width)
.
It defaults to theimage_data_format
value found in your
Keras config file at~/.keras/keras.json
.
If you never set it, then it will be "channels_last". - validation_split=0.0
Fraction of images reserved for validation (strictly between 0 and 1)
网友评论