The most popular programming language for machine learning is Python. Most Data Scientist and ML Engineer build their pipelines with Python. Although Python is a widely used solution, it may not be optimal for all stacks or use cases. In this article, I show you how to use your SavedModel with the current version of Tensorflow Java, which might be useful.
Note: As you may see Tensorflow Java is still under construction. Therefore some unexpected behaviors can happen. Keep this in mind.
First create a Maven project and open your pom.xml. Add the following lines to indicate the Java version. I use Java 11 because it is LTS.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>1.11</maven.compiler.target>
</properties>
Next, add the Tensorflow Java artifacts to your project. At the time of writing this article they are not hosted on maven. Therefore you have to add the OSS repository of Sonatype manually. You can always find the latest instructions in their Github repository Tensorflow/Java.
<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.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
#tensorflow-java #machine-learning #data-science #java #tensorflow