【问题标题】:Can't convert model to tensorflow's lite format无法将模型转换为 tensorflow 的 lite 格式
【发布时间】:2017-11-16 04:57:25
【问题描述】:

我正在尝试在移动设备上使用经过训练的 rnn。问题是,当我使用 toco 将我的 .pb 文件转换为 .tflite 时,它失败并显示以下错误消息:

WARNING: Config values are not defined in any .rc file: opt.
INFO: Found 1 target...
Target //tensorflow/contrib/lite/toco:toco up-to-date:
  bazel-bin/tensorflow/contrib/lite/toco/toco
INFO: Elapsed time: 0.287s, Critical Path: 0.00s

INFO: Running command line: bazel-bin/tensorflow/contrib/lite/toco/toco '--input_file=/Users/valentinradu/Playgrounds/char-rnn-tensorflow/remote_save/latest/graph_frz.pb' '--output_file=/Users/valentinradu/Playgrounds/char-rnn-tensorflow/remote_save/latest/graph.tflite' '--input_format=TENSORFLOW_GRAPHDEF' '--output_format=TFLITE' '--input_type=FLOAT' '--inference_type=FLOAT' '--input_shapes=1,128:1,50,50' '--input_arrays=state_in,data_in' '--output_arrays=state_out,data_out'
2017-11-16 06:48:00.156091: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Fill
2017-11-16 06:48:00.156811: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Fill
2017-11-16 06:48:00.156821: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Pack
2017-11-16 06:48:00.156829: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Pack
2017-11-16 06:48:00.156841: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Unpack
2017-11-16 06:48:00.156856: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: StridedSlice
2017-11-16 06:48:00.156872: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: StridedSlice
2017-11-16 06:48:00.157260: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Pack
2017-11-16 06:48:00.157277: I tensorflow/contrib/lite/toco/import_tensorflow.cc:937] Converting unsupported operation: Pack
2017-11-16 06:48:00.158053: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 40 operators, 64 arrays (0 quantized)
2017-11-16 06:48:00.158141: F tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc:793] Check failed: indices_shape.dimensions_count() == 1 (2 vs. 1)

现在,我知道这是因为 toco 期望我的模型只有一个输入,但是,在我目前发现的示例中,人们使用 2 个输入没有问题。

这与我在模型中使用的操作有关吗? 这是一个已知的限制还是一个错误?

Here 是我构建模型的方式。

【问题讨论】:

    标签: tensorflow tensorflow-lite


    【解决方案1】:

    tf.gather 接受一个indices 参数,即一维整数数组。

    您遇到的错误是,在您的图表中,Gather 操作有一个 indices 数组,该数组是二维的,而不是预期的一维数组。

    更新:我不知道,但在 Gather 中有一个多维索引数组实际上是合法的。将其视为 TFLite Converter (toco) 中的“尚未实现”错误。

    【讨论】:

    • 是的,但期望是因为硬编码值(与我的模型无关)。感谢您的回答!
    • tf.gather 确实支持多维输入,但 toco 的内部表示只能支持更简单的一维形式的收集。虽然 toco 可以代表某些形式的聚集,但 tflite 目前不支持任何形式。
    【解决方案2】:

    不幸的是,这似乎是聚集运算符的限制。我会把它留在这里,以防其他人将来遇到这个问题。

    如果任何对 tensorflow 或团队有更丰富经验的人可以证实这一点,那就太好了!

    【讨论】:

    • 该错误列出了不受支持的操作——您的模型使用的 API 中的内容在 TensorFlow 中,但不在 TensorFlow lite 中。它一直在更新,所以继续尝试,或者关注源代码:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 2019-05-14
    • 2019-04-14
    • 1970-01-01
    相关资源
    最近更新 更多