简体   繁体   English

来自预训练 tensorflow model 的混淆矩阵

[英]Confusion matrix from pre-trained tensorflow model

I trained the mobilenet v1 model of the tensorflow to detect my own classes, but I need to obtain the confusion matrix of the results of the model from the files that were generated, however I cannot find any post that is useful to me to create the matrix of a tensorflow model.我训练了 tensorflow 的 mobilenet v1 model 来检测我自己的类,但是我需要获得 model 的结果的混淆矩阵,该帖子对我创建的文件没有用,但是我无法从生成的文件中找到任何有用的信息tensorflow model 的矩阵。

try this尝试这个

import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from sklearn.metrics import confusion_matrix, classification_report
y_pred=[]
preds= model.predict etc.....
for i, p in enumerate (preds):
    p=pred[i]
    predicted_class_index=np.argmax(p)  # this the the predicted column with highest probability assuming you class_mode='categorical'
    y_pred.append(predicted_class_index) # this is a list of predictions
# now you need to create a list of the corresponding true labels
# how you get this depends on how you supplied the data to model.fit
# but somewhere you should have a list of labels - these are y_true
# then do
cm = confusion_matrix(y_true, y_pred )

if you used the train_gen=ImageDataGenerator.flow_from_directory and set shuffle=False, then y_true=train_gen.labels如果您使用 train_gen=ImageDataGenerator.flow_from_directory 并设置 shuffle=False,则 y_true=train_gen.labels

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow Python未加载预训练的模型 - Tensorflow python not loading the pre-trained model 如何在TensorFlow中使用预训练模型 - How to use pre-trained model in TensorFlow 预训练张量流模型的烧瓶 - flask with pre-trained tensorflow model 如何在 tensorflow 中使用预训练的 model 进行预测? - how to predict with pre-trained model in tensorflow? 如何找到用于物体检测的预训练模型精度和混淆矩阵 - How to find pre-trained model accuracy and confusion matrix for object detection 从预训练的 model 中移除顶层,迁移学习,tensorflow (load_model) - Remove top layer from pre-trained model, transfer learning, tensorflow (load_model) 在从预训练模型进行微调后,丢失TensorFlow模型中的输出节点名称 - Losing output node names in TensorFlow model after fine-tuning from pre-trained model Tensorflow如何修改保存为检查点的预训练模型 - Tensorflow how to modify a pre-trained Model saved as checkpoints 恢复预训练模型的Tensorflow检查点文件 - Restoring Tensorflow checkpoint files of a pre-trained model 如何访问和可视化预训练的 TensorFlow 2 模型中的权重? - How to access and visualize the weights in a pre-trained TensorFlow 2 model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM