11# TensorFlow for Java
22
3- ## Welcome to the Java world of TensorFlow!
4-
5- TensorFlow can run on any JVM for building, training and running machine learning models. It comes with
3+ <table class =" tfo-notebook-buttons " align =" left " >
4+ <td>
5+ <a target="_blank" href="https://www.tensorflow.org/jvm"><img src="https://www.tensorflow.org/images/tf_logo_32px.png" />View on TensorFlow.org</a>
6+ </td >
7+ <td >
8+ <a target="_blank" href="https://github.com/tensorflow/java"><img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />View GitHub repository</a>
9+ </td >
10+ </table >
11+
12+ TensorFlow Java can run on any JVM for building, training and running machine learning models. It comes with
613a series of utilities and frameworks that help achieve most of the tasks common to data scientists
714and developers working in this domain. Java and other JVM languages, such as Scala or Kotlin, are
815frequently used in small-to-large enterprises all over the world, which makes TensorFlow a strategic
916choice for adopting machine learning at a large scale.
1017
11- ## This Repository
18+ ## The Repository
1219
13- In the early days, the Java language bindings for TensorFlow were hosted in the [ main repository] ( https://github.com/tensorflow/tensorflow )
20+ In the early days, the Java language bindings for TensorFlow were hosted in the
21+ [ main TensorFlow repository] ( https://github.com/tensorflow/tensorflow )
1422and released only when a new version of the core library was ready to be distributed, which happens only
1523a few times a year. Now, all Java-related code has been moved to this repository so that it can evolve and
1624be released independently from official TensorFlow releases. In addition, most of the build tasks have been
1725migrated from Bazel to Maven, which is more familiar for most Java developers.
1826
1927The following describes the layout of the repository and its different artifacts:
2028
21- * ` tensorflow-core `
29+ * [ tensorflow-core] ( https://github.com/tensorflow/java/tree/master/tensorflow-core )
2230 * All artifacts that build up the core language bindings of TensorFlow for Java
2331 * Intended audience: projects that provide their own APIs or frameworks on top of
2432 TensorFlow and just want a thin layer to access the TensorFlow runtime from the JVM
25-
26- * ` tensorflow-framework `
33+
34+ * [ tensorflow-framework] ( https://github.com/tensorflow/java/tree/master/tensorflow-framework )
2735 * Primary API for building and training neural networks with TensorFlow
2836 * Intended audience: neural network developers
29- * For more information: [ tensorflow-framework/README.md] ( tensorflow-framework/README.md )
30-
31- * ` ndarray `
37+
38+ * [ ndarray] ( https://github.com/tensorflow/java/tree/master/ndarray )
3239 * Generic utility library for n-dimensional data I/O operations
3340 * Used by TensorFlow but does not depend on TensorFlow
3441 * Intended audience: any developer who needs a Java n-dimensional array implementation, whether or not they
3542 use it with TensorFlow
36-
43+
3744
3845## Communication
3946
@@ -42,117 +49,4 @@ by subscribing to the [jvm@tensorflow.org](https://groups.google.com/a/tensorflo
4249mailing list, or you can simply send pull requests and raise issues to this repository.
4350There is also a [ sig-jvm Gitter channel] ( https://gitter.im/tensorflow/sig-jvm ) .
4451
45- ## Building Sources
46-
47- See [ CONTRIBUTING.md] ( CONTRIBUTING.md#building ) .
48-
49- ## Using Maven Artifacts
50-
51- To include TensorFlow in your Maven application, you first need to add a dependency on either the
52- ` tensorflow-core ` or ` tensorflow-core-platform ` artifacts. The former could be included multiple times
53- for different targeted systems by their classifiers, while the later includes them as dependencies for
54- ` linux-x86_64 ` , ` macosx-x86_64 ` , and ` windows-x86_64 ` , with more to come in the future. There are also
55- ` tensorflow-core-platform-mkl ` , ` tensorflow-core-platform-gpu ` , and ` tensorflow-core-platform-mkl-gpu `
56- artifacts that depend on artifacts with MKL and/or CUDA support enabled.
57-
58- For example, for building a JAR that uses TensorFlow and is targeted to be deployed only on Linux
59- systems, you should add the following dependencies:
60- ``` xml
61- <dependency >
62- <groupId >org.tensorflow</groupId >
63- <artifactId >tensorflow-core-api</artifactId >
64- <version >0.3.1</version >
65- </dependency >
66- <dependency >
67- <groupId >org.tensorflow</groupId >
68- <artifactId >tensorflow-core-api</artifactId >
69- <version >0.3.1</version >
70- <classifier >linux-x86_64${javacpp.platform.extension}</classifier >
71- </dependency >
72- ```
73-
74- On the other hand, if you plan to deploy your JAR on more platforms, you need additional
75- native dependencies as follows:
76- ``` xml
77- <dependency >
78- <groupId >org.tensorflow</groupId >
79- <artifactId >tensorflow-core-api</artifactId >
80- <version >0.3.1</version >
81- </dependency >
82- <dependency >
83- <groupId >org.tensorflow</groupId >
84- <artifactId >tensorflow-core-api</artifactId >
85- <version >0.3.1</version >
86- <classifier >linux-x86_64${javacpp.platform.extension}</classifier >
87- </dependency >
88- <dependency >
89- <groupId >org.tensorflow</groupId >
90- <artifactId >tensorflow-core-api</artifactId >
91- <version >0.3.1</version >
92- <classifier >macosx-x86_64${javacpp.platform.extension}</classifier >
93- </dependency >
94- <dependency >
95- <groupId >org.tensorflow</groupId >
96- <artifactId >tensorflow-core-api</artifactId >
97- <version >0.3.1</version >
98- <classifier >windows-x86_64${javacpp.platform.extension}</classifier >
99- </dependency >
100- ```
101-
102- In some cases, pre-configured starter artifacts can help to automatically include all versions of
103- the native library for a given configuration. For example, the ` tensorflow-core-platform ` ,
104- ` tensorflow-core-platform-mkl ` , ` tensorflow-core-platform-gpu ` , or ` tensorflow-core-platform-mkl-gpu `
105- artifact includes transitively all the artifacts above as a single dependency:
106- ``` xml
107- <dependency >
108- <groupId >org.tensorflow</groupId >
109- <artifactId >tensorflow-core-platform${javacpp.platform.extension}</artifactId >
110- <version >0.3.1</version >
111- </dependency >
112- ```
113-
114- Be aware though that the native library is quite large and including too many versions of it may
115- significantly increase the size of your JAR. So it is good practice to limit your dependencies to
116- the platforms you are targeting. For this purpose the ` -platform ` artifacts include profiles that follow
117- the conventions established on this page:
118- * [ Reducing the Number of Dependencies] ( https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies )
119-
120- ### Snapshots
121-
122- Snapshots of TensorFlow Java artifacts are automatically distributed after each update in the code. To use them, you need
123- to add Sonatype OSS repository in your pom.xml, like the following
124-
125- ``` xml
126- <repositories >
127- <repository >
128- <id >tensorflow-snapshots</id >
129- <url >https://oss.sonatype.org/content/repositories/snapshots/</url >
130- <snapshots >
131- <enabled >true</enabled >
132- </snapshots >
133- </repository >
134- </repositories >
135- <dependencies >
136- <!-- Example of dependency, see section above for more options -->
137- <dependency >
138- <groupId >org.tensorflow</groupId >
139- <artifactId >tensorflow-core-platform</artifactId >
140- <version >0.4.0-SNAPSHOT</version >
141- </dependency >
142- </dependencies >
143- ```
144-
145- ## TensorFlow Version Support
146-
147- This table shows the mapping between different version of TensorFlow for Java and the core runtime libraries.
148-
149- | TensorFlow Java Version | TensorFlow Version |
150- | ------------- | ------------- |
151- | 0.2.0 | 2.3.1 |
152- | 0.3.0 | 2.4.1 |
153- | 0.3.1 | 2.4.1 |
154- | 0.4.0-SNAPSHOT | 2.4.1
155-
156- ## How to Contribute?
15752
158- Contributions are welcome, guidelines are located in [ CONTRIBUTING.md] ( CONTRIBUTING.md ) .
0 commit comments