from keras.preprocessing.image import ImageDataGenerator
datagen = ImageDataGenerator (
rotation_range = 40 ,
width_shift_range = 0.2 ,
height_shift_range = 0.2 ,
rescale= 1 / 255 ,
shear_range = 0.2 ,
zoom_range = 0.2 ,
horizontal_flip = True,
fill_mode = 'nearest' )
rotation_range
是一个度数(0-180)的值,表示随机旋转图片的范围width_shift和height_shift
是在垂直或水平方向上随机平移图片的范围(作为总宽度或高度的一部分)rescale
是一个值,对图像的亮度值进行缩放,这个操作在所有操作之前,例如rescale为1/255时,表示把RGB的值从0-255转换到0-1之间。shear_range
用于随机应用剪切变换zoom_range
用于随机缩放horizontal_flip
50%的随机概率对图像进行水平翻转fill_mode
像素填充策略,在进行旋转或平移之后,需要对图像像素进行填充