【发布时间】:2022-01-15 03:41:37
【问题描述】:
所以我有 3 个图像类,猫、牛和狗。
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','cow'], batch_size=10, shuffle=False)
当我这样做时
test_batches_1.class_indices
我明白了
{'cat': 0, 'dog': 1, 'cow': 2}
当我这样做时:-
test_imgs1, test_labels1 = next(test_batches_1)
print(test_labels1)
我明白了:-
[[1. 0. 0.]
[1. 0. 0.]
[0. 1. 0.]
[0. 1. 0.]
[0. 0. 1.]
[0. 0. 1.]
[0. 0. 1.]
[0. 0. 1.]]
我更正了,因为我有 2 只猫、2 条狗和 4 只牛的照片。 但是,我不明白为什么 cat 的 0 显示为 1,0,0?或 1 表示狗显示为 0,1,0 和 2 表示牛显示为 0,0,1? 谁能帮忙解释一下逻辑?
【问题讨论】:
标签: python keras image-classification