运行 一个没有安装 Tensorflow 的 Tensorflow 模型
Run a Tensorflow model without having Tensorflow installed
我有一个运行良好的 TF 模型,它是用 Python 和 TFlearn 构建的。有没有办法在不安装 Tensorflow 的情况下在另一个系统上 运行 这个模型?它已经过预训练,所以我只需要 运行 通过它的数据。
我知道 tfcompile (),但设置起来似乎相当复杂。还有其他选择吗?
Is there a way to run this model on another system without installing Tensorflow on it? It is already pre-trained, so I just need to run data through it.
是
训练好模型后。使用 tf.python.tools.freeze_graph
和 tf.python.tools.optimize_for_inference_lib
冻结和优化模型以在 Android.
等其他设备上进行推理
上面的输出将是
- 冻结图 protobuf 文件 (.pb)
- 优化图 protobuf 文件 (.pb)
[这些函数会将模型的所有变量转换为常量操作并导出到 protobuf 文件]
使用优化的图形 protobuf 文件并使用 Java 和其他 Tensorflow API 中可用的推理方法加载它。传递数据并获得输出。
[注意你没有安装完整的 Tensorflow,你只需要推理库]
这里演示了一个简单的例子:
https://omid.al/posts/2017-02-20-Tutorial-Build-Your-First-Tensorflow-Android-App.html
它适用于 Android 但程序应该与 Java 相同。
对于 C++:click here
我有一个运行良好的 TF 模型,它是用 Python 和 TFlearn 构建的。有没有办法在不安装 Tensorflow 的情况下在另一个系统上 运行 这个模型?它已经过预训练,所以我只需要 运行 通过它的数据。
我知道 tfcompile (
Is there a way to run this model on another system without installing Tensorflow on it? It is already pre-trained, so I just need to run data through it.
是
训练好模型后。使用 tf.python.tools.freeze_graph
和 tf.python.tools.optimize_for_inference_lib
冻结和优化模型以在 Android.
上面的输出将是
- 冻结图 protobuf 文件 (.pb)
- 优化图 protobuf 文件 (.pb)
[这些函数会将模型的所有变量转换为常量操作并导出到 protobuf 文件]
使用优化的图形 protobuf 文件并使用 Java 和其他 Tensorflow API 中可用的推理方法加载它。传递数据并获得输出。
[注意你没有安装完整的 Tensorflow,你只需要推理库]
这里演示了一个简单的例子:
https://omid.al/posts/2017-02-20-Tutorial-Build-Your-First-Tensorflow-Android-App.html
它适用于 Android 但程序应该与 Java 相同。
对于 C++:click here