【发布时间】:2019-03-30 16:12:17
【问题描述】:
我用 python 制作了以下 SimpleRNN 模型。
python
#Omit
Xtest = np.zeros((1, 10, 1102))
#Omit
pred = model.predict(Xtest, verbose=0)[0]
如你所见,我使用了一个整数的三维数组作为模型的输入。
然后,我将此模型移植到 android 为 .tflite。
在下面的代码中,名为tfliteModel的部分是对应的。
kotlin
Interpreter(tfliteModel!!).use { interpreter ->
val input_onehot = Array(1) { Array(10) {Array<Int>(1102) {0} } }
val output = Array(1) {Array<Float>(1102) { 0F } }
//some operation like making it a one hot vector
interpreter.run(input_onehot, output)
}
但是 Android Studio 抛出了这样的错误:
Caused by: java.lang.IllegalArgumentException: DataType error: cannot resolve DataType of [[[Ljava.lang.Integer;
为什么会出现这个错误? 如何将整数数组加载到模型中?
我使用this site 作为参考。 但是,这是指图像而不是 NLP···
【问题讨论】:
标签: android tensorflow kotlin