我正在尝试微调 MobileNet,但收到以下错误:
ValueError, Error when checking target: expected dense_1 to have 4 dimensions, but got array with shape (10, 14)
与我设置目录迭代器的方式有什么冲突吗?
train_batches = ImageDataGenerator(preprocessing_function=keras.applications.mobilenet_v2.preprocess_input).flow_from_directory(
train_path, target_size=(224, 224), batch_size=10)
valid_batches = ImageDataGenerator(preprocessing_function=keras.applications.mobilenet_v2.preprocess_input).flow_from_directory(
valid_path, target_size=(224, 224), batch_size=10)
test_batches = ImageDataGenerator(preprocessing_function=keras.applications.mobilenet_v2.preprocess_input).flow_from_directory(
test_path, target_size=(224, 224), batch_size=10, shuffle=False)
我的新瓶颈层如下:
x=mobile.layers[-6].output
predictions = Dense(14, activation='softmax')(x)
model = Model(inputs=mobile.input, outputs=predictions)