我想同时向同一个 CNN 模型输入多个图像(8)。我建立了波纹管模型:
inputShape = (height, width, depth)
input1 = Input(shape=(inputShape), name='input1')
input2 = Input(shape=(inputShape), name='input2')
input3 = Input(shape=(inputShape), name='input3')
input4 = Input(shape=(inputShape), name='input4')
input5 = Input(shape=(inputShape), name='input5')
input6 = Input(shape=(inputShape), name='input6')
input7 = Input(shape=(inputShape), name='input7')
input8 = Input(shape=(inputShape), name='input8')
x = concatenate([input1, input2, input3, input4, input5, input6, input7, input8])
conv_1 = Conv2D(filters=32, kernel_size=(3, 3), padding="same", activation="relu", name="conv_1")(x)
batch_norm_1 = BatchNormalization(axis=chanDim)(conv_1)
max_pool1 = MaxPooling2D(pool_size=(2, 2))(batch_norm_1)
drop_out1 = Dropout(0.25)(max_pool1)
conv_2 = Conv2D(filters=64, kernel_size=(3, 3), padding="same", activation="relu", name="conv_2")(drop_out1)
batch_norm_2 = BatchNormalization(axis=chanDim)(conv_2)
max_pool2 = MaxPooling2D(pool_size=(2, 2))(batch_norm_2)
drop_out2 = Dropout(0.25)(max_pool2)
out_01 = Flatten()(drop_out2)
out_02 = Dense(128, activation="relu")(out_01)
out_03 = BatchNormalization(axis=chanDim)(out_02)
out = Dropout(0.5)(out_03)
out2 = Dense(classes, activation="softmax")(out)
model = Model([input1, input2, input3, input4, input5, input6, input7, input8], out2)
这是我的训练
(trainX, testX, trainY, testY) = train_test_split(data, labels, test_size=0.2, random_state=42)
aug = ImageDataGenerator(rotation_range=25, width_shift_range=0.1, height_shift_range=0.1, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode="nearest")
model.compile(loss="categorical_crossentropy", optimizer= opt,
metrics=["accuracy"])
model.fit_generator( aug.flow(trainX, trainY, batch_size=BS), validation_data=(testX, testY), steps_per_epoch=len(trainX) // BS, epochs=EPOCHS, verbose=1)
我在训练模型时遇到了问题,(trainnX,testX,trainY,testY)拍摄一张图像,我怎样才能让它拍摄 8 张图像,以及如何在训练和测试集中将它们分开。我有以下错误:
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 8 array(s), but instead got the following list of 1 arrays: [array([[[[0.96470588, 0.00392157, 0.01568627], ...
TypeError: 'NoneType' object is not callable
谁能帮帮我,非常感谢。
编辑:我指定 trainX, testX 作为列表如下:
([trainX], [testX], trainY, testY) = train_test_split(data, labels, test_size=0.2, random_state=42)
model.fit_generator(aug.flow([trainX], trainY, batch_size=BS), validation_data=([testX], testY), steps_per_epoch=len(trainX) // BS, epochs=EPOCHS, verbose=1)
但它给了我以下错误:
too many values to unpack (expected 1)
请问如何将它们确定为 8 张图片的列表?