我想从以下层开始训练一个深度网络:
model = Sequential()
model.add(Conv2D(32, 3, 3, input_shape=(32, 32, 3)))
使用
history = model.fit_generator(get_training_data(),
samples_per_epoch=1, nb_epoch=1,nb_val_samples=5,
verbose=1,validation_data=get_validation_data()
使用以下生成器:
def get_training_data(self):
while 1:
for i in range(1,5):
image = self.X_train[i]
label = self.Y_train[i]
yield (image,label)
(验证生成器看起来很相似)。
在训练期间,我收到错误:
Error when checking model input: expected convolution2d_input_1 to have 4
dimensions, but got array with shape (32, 32, 3)
怎么可能,第一层
model.add(Conv2D(32, 3, 3, input_shape=(32, 32, 3)))
?