如何修复“TOCO失败”。检查失败:dim>=1(0 vs.1)“将冻结的图形转换为tensorflow_-lite mod时出错

2024-09-29 01:32:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我训练了一个目标探测模型。现在我正尝试使用Tensorflow Lite graph converter提供的量化来加速推理。但是当我调用tf.lite.TFLiteConverter.from_frozen_graph 方法,我遇到了一个错误。在

我还发现大约一年前有人问过similar, unanswered question,我想知道TFLite的支持现在是否有所改善。在

我的意思是:

converter = tf.lite.TFLiteConverter.from_frozen_graph(
    model_path,
    input_arrays = ['input_1'],
    output_arrays = [
        'filtered_detections/map/TensorArrayStack/TensorArrayGatherV3',
        'filtered_detections/map/TensorArrayStack_1/TensorArrayGatherV3',
        'filtered_detections/map/TensorArrayStack_2/TensorArrayGatherV3'
        ],
    input_shapes = { 
        'input_1': [None, 300, 300, 3]
        }
    )
converter.post_training_quantize = True
tflite_quantized_model = converter.convert()

编辑:我也尝试过input_1的不同参数值,比如[1, 300, 300, 3]等。我甚至省略了input_shapes参数,但是它抛出了另一个错误:None is allowed only in 1st dimension. Other dimensions can not be null

以下是错误日志:

^{pr2}$

Tags: frommapinputmodeltf错误litefiltered
1条回答
网友
1楼 · 发布于 2024-09-29 01:32:40

问题出在tflite converter现有的不受支持的tensorflow操作中:

Converting unsupported operation: Enter

Converting unsupported operation: Size

Converting unsupported operation: TensorArrayWriteV3

尝试找到一种方法来避免在原始的张量流图中使用这种操作。在

请参阅this link,其中提供有关TFLite支持的操作的信息。在

相关问题 更多 >