我的模特
model.add(Conv3D(nb_filters[0], kernel_dim1=nb_conv[0],
kernel_dim2=nb_conv[0], kernel_dim3=nb_conv[0],
input_shape=(20, 50, 50,1), activation='relu'))
model.add(MaxPooling3D(pool_size=(nb_pool[0], nb_pool[0], nb_pool[0])))
model.add(Conv3D(nb_filters[1], kernel_dim1=nb_conv[0],
kernel_dim2=nb_conv[0], kernel_dim3=nb_conv[0],activation='relu'))
model.add(MaxPooling3D(pool_size=(nb_pool[0], nb_pool[0], nb_pool[0])))
model.add(Dropout(0.8))
model.add(Flatten())
model.add(Dense(1024, init='normal', activation='relu'))
model.add(Dropout(0.8))
model.add(Dense(nb_classes,init='normal'))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy',optimizer='adadelta',
metrics['accuracy'])
我的输入numpy数组
train_data=np.load('D:/muchdata-50-50-20.npy')
train=train_data[-10:]
test=train_data[-2:]
train1 = np.array([i[0] for i in train]).reshape(-1,20,50,50,1)
y_train = [i[1] for i in train]
testx=np.array([i[0] for i in test]).reshape(-1,20,50,50,1)
testy=[i[1] for i in test]
这是预处理功能
datagen = ImageDataGenerator(featurewise_center=True,
featurewise_std_normalization=True,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True)
这是合适的
datagen.fit(train1)
这样的错误
答案 0 :(得分:0)
对于图像数据生成器,图像形状应设置为等级 4。因此,我认为您的 reshape 命令应该更改(我的建议)。对于 reshape -1
,这实际上意味着“将多维转化为一维”。