[Python] Issue with "IndexError: _Map_base::at" when convert a tensorflow model to tensorflow...

Discussão em 'Python' iniciado por Stack, Setembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I want to test the performance of the quantized tensorflow model .First, I need to quantize the model using tensorflow lite,and got the .tflite model.

    When I converter a tensorflow model .h5 to .tflite,print the error:


    Exception has occurred: IndexError _Map_base::at File tflite_model = converter.convert() IndexError: _Map_base::at"
    ​

    The tensorflow version is V2.4; ubuntu 22.04; RX3090

    The code is as follows: original code

    if __name__ == '__main__':

    dpcrn = DPCRN_model(batch_size = 1,
    length_in_s = 5,
    lr = 1e-3,
    block_len = 400,
    block_shift = 200)
    my_model = dpcrn.build_DPCRN_model()
    converter = tf.lite.TFLiteConverter.from_keras_model(my_model)
    converter.optimizations = [tf.lite.Optimize.DEFAULT]
    converter.target_spec.supported_ops = [tf.lite.OpsSet.SELECT_TF_OPS,tf.lite.OpsSet.TFLITE_BUILTINS_INT8] #
    converter.representative_dataset = representative_data_gen
    tflite_model = converter.convert()

    quant_model_path = './model_tflite.tflite'
    with open(quant_model_path, 'wb') as f:
    f.write(tflite_model)

    Continue reading...

Compartilhe esta Página