我想在一张图像上展示不同数据增强(随机缩放、旋转和平移)的效果。我从 x_train 绘制了第一张图像,但是第二张图似乎没有任何变化。
我想我用错了 datagen.flow,请指教。谢谢。
from matplotlib import pyplot as plt
from tensorflow.python.keras.datasets import cifar10
from tensorflow.python.keras.preprocessing.image import ImageDataGenerator
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x1=x_train[0]
print(x1.shape)
plt.imshow(x1)
plt.show()
# set up image augmentation
datagen = ImageDataGenerator(
rotation_range=180, # Randomly rotate by degrees
width_shift_range=0.2, # For translating image vertically
height_shift_range=0.2, # For translating image horizontally
horizontal_flip=True,
rescale=None,
fill_mode='nearest'
)
datagen.fit(x_train)
# see example augmentation images
x_batch = datagen.flow(x_train)
x2=x_batch[0]
print(x2.shape)
x2 的输出形状是 (32, 32, 32, 3) 这就是我无法绘制它的原因。为什么尺寸会这样,我该怎么办?