Python 是否可以使用tf.lite模型创建混淆矩阵
我试图展示python模型及其转换模型tf.lite的准确性 为了做到这一点,我决定创建混淆矩阵,对于pyhton模型,很容易创建混淆矩阵,但是对于tf.lite模型,我找不到一种方法来创建混淆矩阵。 这就是为什么有一种方法来制作或者有任何示例来查看它是如何制作的,我发现了如何在python上使用下面的代码运行它Python 是否可以使用tf.lite模型创建混淆矩阵,python,tensorflow,tensorflow-lite,confusion-matrix,Python,Tensorflow,Tensorflow Lite,Confusion Matrix,我试图展示python模型及其转换模型tf.lite的准确性 为了做到这一点,我决定创建混淆矩阵,对于pyhton模型,很容易创建混淆矩阵,但是对于tf.lite模型,我找不到一种方法来创建混淆矩阵。 这就是为什么有一种方法来制作或者有任何示例来查看它是如何制作的,我发现了如何在python上使用下面的代码运行它 import numpy as np import tensorflow as tf # Load the TFLite model and allocate tensors. in
import numpy as np
import tensorflow as tf
# Load the TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="converted_model.tflite")
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test the model on random input data.
input_shape = input_details[0]['shape']
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
# The function `get_tensor()` returns a copy of the tensor data.
# Use `tensor()` in order to get a pointer to the tensor.
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
但我还是没有主意
谢谢