如何确定 Keras classifier 模型中预测的 class?
How to determine the predicted class in Keras classifier model?
我训练了一个基于this tutorial的模型。现在,当我对单个图像使用 model.predict
时,输出值为 [[0.19530062 0.80469936]]
.
我该如何解读这个回复?我的意思是这两个值代表什么,即每个值属于哪个class?如果我要选择猫还是狗,那么如何根据上述输出值确定预测的是猫还是狗?
如果您想知道这些值的含义,那么您可以在这里找到答案:
但是,如果你想在使用flow_from_directory
方法后找出ImageDataGenerator
中哪个class被映射为0和1,那么你可以使用class_indices
属性:
class_mapping = train_data_gen.class_indices
classes: Optional list of class subdirectories (e.g. ['dogs', 'cats']
). Default: None
. If not provided, the list of classes will be automatically inferred from the subdirectory names/structure under directory
, where each subdirectory will be treated as a different class (and the order of the classes, which will map to the label indices, will be alphanumeric). The dictionary containing the mapping from class names to class indices can be obtained via the attribute class_indices
.
我训练了一个基于this tutorial的模型。现在,当我对单个图像使用 model.predict
时,输出值为 [[0.19530062 0.80469936]]
.
我该如何解读这个回复?我的意思是这两个值代表什么,即每个值属于哪个class?如果我要选择猫还是狗,那么如何根据上述输出值确定预测的是猫还是狗?
如果您想知道这些值的含义,那么您可以在这里找到答案:
但是,如果你想在使用flow_from_directory
方法后找出ImageDataGenerator
中哪个class被映射为0和1,那么你可以使用class_indices
属性:
class_mapping = train_data_gen.class_indices
classes: Optional list of class subdirectories (e.g.
['dogs', 'cats']
). Default:None
. If not provided, the list of classes will be automatically inferred from the subdirectory names/structure underdirectory
, where each subdirectory will be treated as a different class (and the order of the classes, which will map to the label indices, will be alphanumeric). The dictionary containing the mapping from class names to class indices can be obtained via the attributeclass_indices
.