【发布时间】:2017-12-08 23:32:26
【问题描述】:
我正在学习如何使用 Keras 和 CIFAR-10 数据集实现数据增强。我正在借助在线教程和本书Deep learning with Keras.
代码的具体细节是here。
这是我的问题,我确信这与我的一些误解有关:
这是我的 CONV 设置。
IMG_CHANNELS = 3
IMG_ROWS = 32
IMG_COLS = 32
BATCH_SIZE = 128
NB_EPOCH = 50
NB_CLASSES = 10
VERBOSE = 1
VALIDATION_SPLIT = 0.2
OPTIM = RMSprop()
加载数据集,转换为分类、浮点和规范化:
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
Y_train = np_utils.to_categorical(y_train, NB_CLASSES)
Y_test = np_utils.to_categorical(y_test, NB_CLASSES)
X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
X_train /= 255
X_test /= 255
创建生成器
datagen = ImageDataGenerator(
featurewise_center=False, # set input mean to 0 over the dataset
samplewise_center=False, # set each sample mean to 0
featurewise_std_normalization=False, # divide inputs by std of the dataset
samplewise_std_normalization=False, # divide each input by its std
zca_whitening=False, # apply ZCA whitening
rotation_range=0, # randomly rotate images in the range (degrees, 0 to 180)
width_shift_range=0.1, # randomly shift images horizontally (fraction of total width)
height_shift_range=0.1, # randomly shift images vertically (fraction of total height)
horizontal_flip=True, # randomly flip images
vertical_flip=False) # randomly flip images
datagen.fit(X_train)
训练模型(我没有列出模型)
model.fit_generator(datagen.flow(X_train, Y_train,
batch_size=BATCH_SIZE),
samples_per_epoch=X_train.shape[0],
nb_epoch=NB_EPOCH,
verbose=VERBOSE)
我的问题是,当我训练时,会显示以下内容:
Epoch 1/40
390/390 [==============================] - 199s - loss: 0.9751 - acc: 0.6588
我不明白为什么我会收到 390 个示例。 Samples_per_epoch 等于 X_train.shape[0] ,即 50000,批量大小为 128,所以我认为它应该以 128 个批次增加到 50000。
【问题讨论】:
标签: python tensorflow keras neural-network deep-learning