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 如何从量化的TFLite中获取类索引?_Python_Tensorflow_Tensorflow Lite - Fatal编程技术网

Python 如何从量化的TFLite中获取类索引?

Python 如何从量化的TFLite中获取类索引?,python,tensorflow,tensorflow-lite,Python,Tensorflow,Tensorflow Lite,我一直在用TensorFlow训练一个量化的Mobilenet V2,但我不知道如何从中获得类索引 我使用的是Tensorflow 1.12 下面是我的输入和输出详细信息 Input details [{'name': 'normalized_input_image_tensor', 'index': 260, 'shape': array([ 1, 300, 300, 3], dtype=int32), 'shape_signature': array([ 1, 300, 300,

我一直在用TensorFlow训练一个量化的Mobilenet V2,但我不知道如何从中获得类索引

我使用的是Tensorflow 1.12

下面是我的输入和输出详细信息

Input details [{'name': 'normalized_input_image_tensor', 'index': 260, 'shape': array([  1, 300, 300,   3], dtype=int32), 'shape_signature': array([  1, 300, 300,   3], dtype=int32), 'dtype': <class 'numpy.uint8'>, 'quantization': (0.0078125, 128), 'quantization_parameters': {'scales': array([0.0078125], dtype=float32), 'zero_points': array([128], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]
Output details [{'name': 'TFLite_Detection_PostProcess', 'index': 252, 'shape': array([ 1, 10,  4], dtype=int32), 'shape_signature': array([ 1, 10,  4], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}, {'name': 'TFLite_Detection_PostProcess:1', 'index': 253, 'shape': array([ 1, 10], dtype=int32), 'shape_signature': array([ 1, 10], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}, {'name': 'TFLite_Detection_PostProcess:2', 'index': 254, 'shape': array([ 1, 10], dtype=int32), 'shape_signature': array([ 1, 10], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}, {'name': 'TFLite_Detection_PostProcess:3', 'index': 255, 'shape': array([1], dtype=int32), 'shape_signature': array([1], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]
然而,分类指数是不正确的。打印时,
如下所示:
[0.0.0.0.0.0.0.0.]
。我的数据集中有1个以上的类,所以这没有任何意义

获取类索引的正确方法是什么?

尝试使用:

classes = interpreter.get_tensor(output_details[0]['index'])

经过大量实验,结果证明这不是一个量化问题。我们在创建.tflite时使用了错误的
graph\u def
.pb文件,因此它预测了不存在的类。

我的问题不是索引类张量,而是值的问题<代码>类看起来像这样:
[0.0.0.0.0.0.0.0.]
当我打印它的时候。看起来像模型预测什么。你能用tf2吗?tf1不再受支持。据我所知,我们正在使用tf2尚不支持的slim。您的任务是分类还是对象检测?对象检测。
classes = interpreter.get_tensor(output_details[0]['index'])