Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 是否可以使用tf.lite模型创建混淆矩阵_Python_Tensorflow_Tensorflow Lite_Confusion Matrix - Fatal编程技术网

Python 是否可以使用tf.lite模型创建混淆矩阵

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

我试图展示python模型及其转换模型tf.lite的准确性 为了做到这一点,我决定创建混淆矩阵,对于pyhton模型,很容易创建混淆矩阵,但是对于tf.lite模型,我找不到一种方法来创建混淆矩阵。 这就是为什么有一种方法来制作或者有任何示例来查看它是如何制作的,我发现了如何在python上使用下面的代码运行它

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)
但我还是没有主意

谢谢