Tensorflow lite debug过程

报错:None is only supported in the 1st dimension.

加入input_shapes={“input_1”:[1,600,500,3]}

import tensorflow as tf

graph_def_file = "./models/wdsr-a-32-x4-psnr-29.1736.pb"
input_arrays = ["input_1"]
output_arrays = ["lambda_5/add"]

converter = tf.lite.TFLiteConverter.from_frozen_graph(
  graph_def_file, input_arrays, output_arrays,input_shapes={"input_1":[1,600,500,3]})
tflite_model = converter.convert()
open("wdsr_-x4-converted_model.tflite", "wb").write(tflite_model)

Some of the operators in the model are not supported by the standard TensorFlow Lite runtime.

If those are native TensorFlow operators, you might be able to use the extended runtime by passing --enable_select_tf_ops, or by setting target_ops=TFLITE_BUILTINS,SELECT_TF_OPS when calling tf.lite.TFLiteConverter(). Otherwise, if you have a custom implementation for them you can disable this error with --allow_custom_ops, or by setting allow_custom_ops=True when calling tf.lite.TFLiteConverter(). Here is a list of builtin operators you are using: ADD, CONV_2D, MUL, SUB, TANH. Here is a list of operators for which you will need custom implementations: DEPTH_TO_SPACE.
原因是使用了lite没有定义的层:
参考官方文档:https://www.tensorflow.org/lite/guide/ops_custom
https://www.tensorflow.org/lite/guide/ops_compatibility (指出tflite支持的运算,不支持tf.depth_to_space)
加入:

converter.allow_custom_ops=True        (useless,需要自己重新写该函数)

TensorFlow pip installation issue: cannot import name ‘descriptor’

pip uninstall protobuf
conda install protobuf

ModuleNotFoundError: No module named ‘absl’

conda install absl-py

‘Uninstalling a distutils installed project’ error when installing blockstack

pip install xxx --ignore-installed xxx

你可能感兴趣的:(Tensorflow)