【发布时间】:2022-01-14 23:31:23
【问题描述】:
这是我的代码:-
test_batches_1 = ImageDataGenerator(preprocessing_function=tf.keras.applications.vgg16.preprocess_input) \
.flow_from_directory(directory=test_path_1, target_size=(224,224), classes=['cat', 'dog'], batch_size=10, shuffle=False)
m_p = model.predict(x=test_batches_1, steps=len(test_batches_1), verbose=0)
其中 model 是指 vgg16 模型减去最后一层和带有 softmax 函数的自定义密集层。
model = Sequential()
for layer in vgg16_model.layers[:-1]:
model.add(layer)
for layer in model.layers:
layer.trainable = False
model.add(Dense(units=2, activation='softmax'))
现在,预测应该按字母顺序排列。
我的文件夹中有以下图片
cat.14.jpg
cat.2.jpg
cat.14 的预测先于 cat.2
如何确保它不会发生并且 14 在 2 之后?
【问题讨论】:
标签: python tensorflow keras