在Swift的TensorFlowLite中获取预测



我在此指令中启动代码:https://www.tensorflow.org/lite/guide/inference#load_and_run_a_model_in_swift

一切正常,但我不明白如何获得预测值。我尝试过:print(outputTensor,但得到了:

Tensor(name: "Identity", dataType: TensorFlowLite.Tensor.DataType.float32, shape: TensorFlowLite.Tensor.Shape(rank: 2, dimensions: [1, 3]), data: 12 bytes, quantizationParameters: nil)

您尝试过示例指南中的这一部分吗

// Copy output to `Data` to process the inference results.
let outputSize = outputTensor.shape.dimensions.reduce(1, {x, y in x * y})
let outputData =
UnsafeMutableBufferPointer<Float32>.allocate(capacity: outputSize)
outputTensor.data.copyBytes(to: outputData)

然后只打印输出数据缓冲区

相关内容

  • 没有找到相关文章

最新更新