【问题标题】:Cannot resolve method 'feed' while using TensorflowInterfenceInterface methods使用 TensorflowInterfenceInterface 方法时无法解析方法“feed”
【发布时间】:2018-07-18 05:47:40
【问题描述】:

我正在我的 android 项目中实现 TensorFlowInferenceInterface。但我发现无法解析方法 'feed(java.lang.String, java.lang.reflect.Array, long, java.lang.long,java.lang.long,?) 错误。我该如何解决?

import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
.......

private TensorFlowInferenceInterface tensorFlowInference;
.......
tensorFlowInference.feed(inputName, imageNormalizedPixels,1L, imageSize, imageSize, COLOR_CHANNELS.toLong())

我无法实现 TensorFlowInferenceInterface 的 feed、run、fetch 等方法。

【问题讨论】:

  • 也发布您的接口代码。

标签: android tensorflow


【解决方案1】:

我解决了一个类似的重视参数类型的问题。

在我解决我的问题之前,我的pixelArrayfloat[][],因为我认为它是一个图像。我用的时候:

inferenceInterface.feed(INPUTNAME, pixelArray,  1, HEIGHT, WIDTH, 1);

我明白了:

无法解析方法'feed(java.lang.String, float[][], int, int, int, int)'

然后我把pixelArray变成float[],问题就解决了。

我以float 输入为例,注意方法提要是public void feed(String inputName, float[] src, long... dims)。但是在您的代码中,COLOR_CHANNELS.toLong() 对应于“?”在你得到的东西中,imageNormalizedPixels 对应于java.lang.reflect.Array

我找到了一个关于java.lang.reflect.Array的描述:“它基于多维数组创建数组,而一维数组只是特殊的实现。”

所以我认为您的 imageNormalizedPixels 可能不是一维数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 2016-01-15
    • 2015-06-10
    相关资源
    最近更新 更多