Monkeying around with TensorFlow 2.3 Java from Scala
There is a new version of TensorFlow Java that installs easily.
Status Starter Project for TensorFlow on Scala
Currently this project is the TensorFlow Java hello world project but setup in Scala. One purpose is to check how well TensorFlow works with Scala on different platforms.
So far the results has been good: This installs cleanly on Linux, macOS and Windows.
Might also test out prebuild models for TensorFlow on different platforms.
cd tensorzoo sbt test sbt run
TensorFlow 2.3.1 Scala 3.0.0-M3 Scala 2.13.4
- Oracle JDK 8
- OpenJDK 11
It has been tested on
- macOS 11.1
- Ubuntu 20.04 running under WSL2
- Windows 10
Calling Java from Scala
The TensorFlow Java bindings are using Java generics that are pretty different from Scala generics.
Legacy TensorFlow Java and New TensorFlow Java Bindings
Legacy TensorFlow Java Binding
Legacy Java https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java.
There is better documentation for legacy including LabelImage.java example project.
Porting Legacy Example
Tried to port Legacy Java example to Scala and new Java bindings: LabelImage.scala. That was not easy, so it is currently incomplete.
New TensorFlow Java Binding
New Java https://github.com/tensorflow/java.
Interface is quite different from legacy Java bindings.
Related Project TensorFlow Scala
There is a good project TensorFlow Scala with idiomatic Scala bindings. Here is a starter project.