我正在尝试为 Android 构建一个离线翻译器。我的模型深受本指南的启发: https: //www.tensorflow.org/tutorials/text/nmt_with_attention。我只是做了一些修改以确保模型是可序列化的。(您可以在最后找到模型的代码)
该模型在我的 jupyter 笔记本上完美运行。我使用的 Tensorflow 版本:2.3.0-dev20200617,我还能够使用以下代码片段生成 tflite 文件:
converter = tf.lite.TFLiteConverter.from_keras_model(partial_model)
tflite_model = converter.convert()
with tf.io.gfile.GFile('goog_nmt_v2.tflite', 'wb') as f:
f.write(tflite_model)
Run Code Online (Sandbox Code Playgroud)
但是,当我使用生成的 tflite 模型来获取 Android 上的预测时,它会抛出错误java.lang.IllegalArgumentException: Internal error: Failed to run on the given Interpreter: tensorflow/lite/kernels/concatenation.cc:73 t->dims->data[d] != t0->dims->data[d] (8 != 1) Node number 84 (CONCATENATION) failed to prepare.
这很奇怪,因为我提供了与我在 jupyter 笔记本中完全相同的输入尺寸。以下是用于测试(虚拟输入)模型是否在 Android 上运行的 java 代码:
HashMap<Integer, Object> outputVal = new HashMap<>();
for(int i=0; i<2; i++) outputVal.put(i, new float[1][5]);
float[][] inp_test = new float[1][8];
float[][] …Run Code Online (Sandbox Code Playgroud) 我最近被介绍到 MongoDB 并通过安装指南我开始知道我们必须首先运行守护程序(mongod),然后我们必须通过 mongo.exe(对于 Windows)连接到守护程序才能实际运行命令。我注意到这是大多数 DBMS 的通用结构,我们必须在其中启动服务器,然后连接到它来运行命令。
为什么我们不能像使用 Python 或 Node.js 那样在单个程序实例中运行 DBMS?具体来说,为什么我们需要 DBMS 的服务器-客户端架构?
我需要在 Kotlin 中将二进制字符串转换为 Int 或 Long。是否有任何内置实用方法可用于相同目的?