我正在尝试通过使用数据增强来提高使用 Xception 作为预训练模型的迁移学习模型的性能。目标是对犬种进行分类。train_tensors
并将valid_tensors
训练和测试图像分别包含在一个 numpy 数组中。
from keras.applications.xception import Xception
model = Xception(include_top = False, weights = "imagenet")
datagen = ImageDataGenerator(zoom_range=0.2,
horizontal_flip=True,
width_shift_range = 0.2,
height_shift_range = 0.2,
fill_mode = 'nearest',
rotation_range = 45)
batch_size = 32
bottleneck_train = model.predict_generator(datagen.flow(train_tensors,
train_targets,
batch_size = batch_size),
train_tensors.shape[0]// batch_size)
bottleneck_valid = model.predict_generator(datagen.flow(valid_tensors,
valid_targets,
batch_size = batch_size),
test_tensors.shape[0]//batch_size)
print(train_tensors.shape)
print(bottleneck_train.shape)
print(valid_tensors.shape)
print(bottleneck_valid.shape)
但是,最后 4 行的输出是:
(6680, 224, 224, 3)
(6656, 7, 7, 2048)
(835, 224, 224, 3)
(832, 7, 7, 2048)
predict_generator 函数返回的样本数量与其提供给它的样本不同。样品是否被跳过或遗漏?