简体   繁体   English

我们如何将 tensorflow 2.x 模型导入 Java?

[英]How can we import a tensorflow 2.x model to Java?

Since Tensorflow's Java API is still using 1.15, can we import a model made with Python and version 2.x to Java.由于 Tensorflow 的 Java API 仍然使用 1.15,我们可以将使用 Python 和 2.x 版本制作的模型导入 Java。 If so, how?如果是这样,如何?

TensorFlow 2.x support for Java is actually in progress and available only through snapshots on Sonatype OSS. TensorFlow 2.x 对 Java 的支持实际上正在进行中,并且只能通过 Sonatype OSS 上的快照获得。

If you add this to your POM, you should be able to load and use them.如果你把它添加到你的 POM 中,你应该能够加载和使用它们。 Note that this only works for Linux and MacOSx at the moment since there is a bug with the Windows build.请注意,这目前仅适用于 Linux 和 MacOSx,因为 Windows 版本存在错误。 Also, the API varies a bit from the 1.15 version so you might need to adapt some pieces of code.此外,API 与 1.15 版本略有不同,因此您可能需要修改一些代码。

 <repositories>
    <repository>
        <id>tensorflow-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
 </repositories>
 <dependencies>
    <dependency>
        <groupId>org.tensorflow</groupId>
        <artifactId>tensorflow-core-platform</artifactId>
        <version>0.1.0-SNAPSHOT</version>
    </dependency>
 </dependencies>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM