【问题标题】:how to interpret output tensor data packing in tensorflow lite c++?如何解释 tensorflow lite c++ 中的输出张量数据打包?
【发布时间】:2021-04-01 18:12:37
【问题描述】:

我正在用 c++ 开发一个 tensorflow-lite 模型(我已经让它在 python 中工作了),我对如何打包输出数据感到困惑。我在文档中找不到任何参考资料。我查看了 tflite 源代码,了解到我可以使用 dims 获取张量的输出维度

for(int i=0; i < size; i++){
print("%d\n", out_tensor->dims->data[i]);
}

这给了我:

1
96
96
14

这正是我所知道的输出数据。它是一个 96x96 的网格,其中每个网格元素是 14 个浮点数。我不明白的是如何正确获取这些数据。一开始我们以为它是平的,然后像这样把它拉出来:

  const float* output = interpreter->typed_output_tensor<float>(0);

  for (int j = 0; j < num_values; ++j) {
    output_data_flat[out_idx++] = output[j];
  }

但这似乎并不正确。解压此输出数据的正确方法或至少是干净的方法是什么?

谢谢。

【问题讨论】:

    标签: c++ tensorflow-lite


    【解决方案1】:

    TensorFlow Lite 张量数据以连续方式存储,这意味着您可以假设它是扁平的。

    换句话说,您可以假设interpreter-&gt;typed_output_tensor&lt;float&gt;(0) 为float[1][96][96][14]。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-18
      • 1970-01-01
      • 1970-01-01
      • 2019-04-08
      • 2018-11-26
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      相关资源
      最近更新 更多