Deep Learning for Java Developers
San Francisco Java User Group
Suyash Joshi
Principal Developer Marketing Director
Oracle, Marketing
April 14, 2020
@java
@suyashcjoshi
#ai
Safe harbor statement
The following is intended to outline our general product direction. It is intended for information
purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any
material, code, or functionality, and should not be relied upon in making purchasing decisions. The
development, release, timing, and pricing of any features or functionality described for Oracle’s
products may change and remains at the sole discretion of Oracle Corporation.
2
Overview
1 WhoAmI & WhoAreYou
2 Why Java & ML
3 Machine (Deep) Learning 101 & ML Engineering Overview
4 ML with Java – Live Coding & Demo of Tools, Libraries, Frameworks
5 Q&A
3
Suyash Joshi
Developer Evangelist / Developer Marketing
SF Bay Area Based, Organizer of Various Meetups Groups
Enterprise Java Developers (6+ years)
AI for Creative Purpose
Loves to perform Magic & Juggling
4
5
Audience Poll
Why do you want to learn more about
Machine Learning/Deep Learning in Java ?
1. Interested from Data Scientist/ML
Researcher perspective
2. Interested from a Java Developer (ML in
Production, ML Ops etc.)
3. General ML/DL interest
What is your current level of understanding with Deep
Learning/Machine Learning frameworks in general ?
1. Not at all
2. Some/beginner Level
3. Intermediate/Advance Level
6
AI - Big Picture
7
The Modern ML Pipeline Lifecycle
Subtitle
8
What Role will you play ?
9
Data Engineer or Data Scientist ?
10
Oracle Cloud Data Science Platform
• Oracle Big Data Service : Fully configured version of Cloudera Enterprise
• Oracle Cloud Infrastructure Data Flow : Fully managed Apache Spark
• OML Notebooks OML & Algorithms – SQL Notebooks on Autonomous Database
• OML4R & OML4Py : R & Python Notebooks for Data Scientists
• OML4Spark - process data in Data Lakes using Spark & Hadoop
• OML Microservices GPUs : Coming soon
• Oracle Cloud Infrastructure Data Science Service
• Pre Configured VM’s – NVIDIA GPU’s with Preinstalled Notebooks, Frameworks
ML Engineer / Software Engineer ?
11
Reference: https://medium.com/@tomaszdudek/but-what-is-this-machine-learning-engineer-actually-doing-18464d5c699
Building ML Services
12
Sample RESTful Services
State of Deep Learning Java Frameworks*
13
Framework / Library Strengths Weakness License
TensorFlow for Java Popular in the industry.
Google is the main contributor,
TF-Java SIG has active developer
community online
Java API, currently
experimental, not 2.0,
stable version – 1.14
Apache 2.0
PyTorch for Java Researchers/Academics love it.
Open AI Support. Facebook is the
main contributor
Lacking Documentation,
Examples. Currently only
useful for inferencing
BSD
DJL (Deep Java Learning) High Level API’s with Engine
Architecture. Support for MXNet,
TensorFlow & PyTorch models. AWS
Research is the main contributor,
active development going on.
An abstraction on top of
MXNet for Java
Apache 2.0
DL4J Supports large number of models,
GPU, distributed training with Spark.
Lot’s of interesting examples, good
documentation. Most Mature.
API are hard to follow and
understand for non-expert
users, Framework is too
bloated
Apache 2.0
Simple Neural Network
14
Feed Forward Neural Net (not showing Back Propagation)
A directed graph, with
nodes organized into
groups called layers
Each node performs
computation on it’s
inputs
Computation can be
reconfigured by
tweaking coefficients
assigned to edges
Steps in an ML Program
15
• Define the neural network that has some learnable parameters (or weights)
• Iterate over a dataset of inputs
• Process input through the network
• Compute the loss (how far is the output from being correct)
• Propagate gradients back into the network’s parameters
• Update the weights of the network, until Model Fits
Steps to build a simple Linear Regression Model
16
Reference: https://github.com/JavaVisRec/visrec-api/wiki/Getting-Started-Guide
Goal: Fit the Curve (linear
function)
Model: y = mx + c
Y = output / prediction
X = input
M, b : adjustable values (weights,
biases)
Data on 2 Variables:
X-Axis : Dependent
Y-Axis : Independent
https://github.com/JavaVisRec/jsr381-examples/blob/master/src/main/java/jsr381/example/SimpleLinearRegressionExample.java
Not so simple Model
17
Reference: https://dzone.com/articles/activation-functions-and-optimizers-for-deep-learn
TensorFlow Open Source Project
18
Reference: https://www.tensorflow.org
TensorFlow for Java Open Source Project
19
“Tensorflow works in Java, you can run training and inference with the same core
functionality as python. The TF JVM SIG is building a new Java API, which will
make these things even simpler, and allow training runs without a line of python
code.
They are building a Keras style API to make DL easier to use, and working on
better integration with the JVM ecosystem including languages like Scala and
Kotlin. If you want to come help you can find them
at github.com/tensorflow/java or on gitter.”
- Dr. Adam Pocock (ML Researcher, Oracle Labs)
https://www.tensorflow.org/install/lang_java
ML Development – Notebook (Jupyter, Apache Zeppelin) Programming
20
https://github.com/SpencerPark/IJava
https://dzone.com/articles/apache-zeppelin-stairway-to-notes-haven
Live Demo
• TensorFlow with Java
• DJL
• VisRec API
21 Copyright © 2020, Oracle and/or its affiliates | Confidential: Internal/Restricted/Highly Restricted [Date]
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow</artifactId>
<version>1.14.0</version>
</dependency>
Version 2.0 in tensorflow/java
Repository, will be merged to
Tensorflow/tensorflow repository
and documentation will be updated
ML Deployment and Monitoring with Java API Support
22
https://oracle.github.io/graphpipe,
https://github.com/mlflow/mlflow/blob/master/mlflow/java/client/README.md
ML Deployment - ONNX
23
https://github.com/microsoft/onnxruntime
Open Neural Network Exchange
- Framework Interoperability
- Pretrained ONNX Models (Zoo)
- ONNX Tools: Export to ONNX Format
- ONNX Tools: Model Optimization
- ONNX Runtime Java Support
- Microsoft, Facebook, Oracle (Adam) etc
Java Ecosystem – JSR381 (Visrual Recognition)
24
https://github.com/JavaVisRec/visrec-ri
25
Audience Poll
How would you like learn/hear more in
order to succeed ML and Java?
1. YouTube / Video tutorials
2. Blogs, How To Guide etc.
3. Live Training / Live Online Sessions
What would you like to learn/hear more about?
1. Cool / Interesting examples (Text, Image, Audio, Video
etc.) using ML Frameworks/Toolkits (DL4J, TF-Java,
PyTorch-Java, DJL etc.)
2. Cloud Native Java/Jakarta EE ML Use Cases:
MLOps(Deployment), Microservices-Kubernetes for ML
Services, Deployment and Updates
3. Python based TF, PyTorch Tutorials etc.
Our mission is to help Java developers
succeed with AI, join us and help in
whatever way possible.
Thank You
Suyash Joshi
suyash@suyashjoshi.com
yash.joshi@oracle.com
27
Learning resources:
- Twitter @suyashcjoshi @java #ai
- Email me and I’ll share more information

Deep Learning for Java Developer - Getting Started

  • 1.
    Deep Learning forJava Developers San Francisco Java User Group Suyash Joshi Principal Developer Marketing Director Oracle, Marketing April 14, 2020 @java @suyashcjoshi #ai
  • 2.
    Safe harbor statement Thefollowing is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. 2
  • 3.
    Overview 1 WhoAmI &WhoAreYou 2 Why Java & ML 3 Machine (Deep) Learning 101 & ML Engineering Overview 4 ML with Java – Live Coding & Demo of Tools, Libraries, Frameworks 5 Q&A 3
  • 4.
    Suyash Joshi Developer Evangelist/ Developer Marketing SF Bay Area Based, Organizer of Various Meetups Groups Enterprise Java Developers (6+ years) AI for Creative Purpose Loves to perform Magic & Juggling 4
  • 5.
    5 Audience Poll Why doyou want to learn more about Machine Learning/Deep Learning in Java ? 1. Interested from Data Scientist/ML Researcher perspective 2. Interested from a Java Developer (ML in Production, ML Ops etc.) 3. General ML/DL interest What is your current level of understanding with Deep Learning/Machine Learning frameworks in general ? 1. Not at all 2. Some/beginner Level 3. Intermediate/Advance Level
  • 6.
  • 7.
    AI - BigPicture 7
  • 8.
    The Modern MLPipeline Lifecycle Subtitle 8
  • 9.
    What Role willyou play ? 9
  • 10.
    Data Engineer orData Scientist ? 10 Oracle Cloud Data Science Platform • Oracle Big Data Service : Fully configured version of Cloudera Enterprise • Oracle Cloud Infrastructure Data Flow : Fully managed Apache Spark • OML Notebooks OML & Algorithms – SQL Notebooks on Autonomous Database • OML4R & OML4Py : R & Python Notebooks for Data Scientists • OML4Spark - process data in Data Lakes using Spark & Hadoop • OML Microservices GPUs : Coming soon • Oracle Cloud Infrastructure Data Science Service • Pre Configured VM’s – NVIDIA GPU’s with Preinstalled Notebooks, Frameworks
  • 11.
    ML Engineer /Software Engineer ? 11 Reference: https://medium.com/@tomaszdudek/but-what-is-this-machine-learning-engineer-actually-doing-18464d5c699
  • 12.
  • 13.
    State of DeepLearning Java Frameworks* 13 Framework / Library Strengths Weakness License TensorFlow for Java Popular in the industry. Google is the main contributor, TF-Java SIG has active developer community online Java API, currently experimental, not 2.0, stable version – 1.14 Apache 2.0 PyTorch for Java Researchers/Academics love it. Open AI Support. Facebook is the main contributor Lacking Documentation, Examples. Currently only useful for inferencing BSD DJL (Deep Java Learning) High Level API’s with Engine Architecture. Support for MXNet, TensorFlow & PyTorch models. AWS Research is the main contributor, active development going on. An abstraction on top of MXNet for Java Apache 2.0 DL4J Supports large number of models, GPU, distributed training with Spark. Lot’s of interesting examples, good documentation. Most Mature. API are hard to follow and understand for non-expert users, Framework is too bloated Apache 2.0
  • 14.
    Simple Neural Network 14 FeedForward Neural Net (not showing Back Propagation) A directed graph, with nodes organized into groups called layers Each node performs computation on it’s inputs Computation can be reconfigured by tweaking coefficients assigned to edges
  • 15.
    Steps in anML Program 15 • Define the neural network that has some learnable parameters (or weights) • Iterate over a dataset of inputs • Process input through the network • Compute the loss (how far is the output from being correct) • Propagate gradients back into the network’s parameters • Update the weights of the network, until Model Fits
  • 16.
    Steps to builda simple Linear Regression Model 16 Reference: https://github.com/JavaVisRec/visrec-api/wiki/Getting-Started-Guide Goal: Fit the Curve (linear function) Model: y = mx + c Y = output / prediction X = input M, b : adjustable values (weights, biases) Data on 2 Variables: X-Axis : Dependent Y-Axis : Independent https://github.com/JavaVisRec/jsr381-examples/blob/master/src/main/java/jsr381/example/SimpleLinearRegressionExample.java
  • 17.
    Not so simpleModel 17 Reference: https://dzone.com/articles/activation-functions-and-optimizers-for-deep-learn
  • 18.
    TensorFlow Open SourceProject 18 Reference: https://www.tensorflow.org
  • 19.
    TensorFlow for JavaOpen Source Project 19 “Tensorflow works in Java, you can run training and inference with the same core functionality as python. The TF JVM SIG is building a new Java API, which will make these things even simpler, and allow training runs without a line of python code. They are building a Keras style API to make DL easier to use, and working on better integration with the JVM ecosystem including languages like Scala and Kotlin. If you want to come help you can find them at github.com/tensorflow/java or on gitter.” - Dr. Adam Pocock (ML Researcher, Oracle Labs) https://www.tensorflow.org/install/lang_java
  • 20.
    ML Development –Notebook (Jupyter, Apache Zeppelin) Programming 20 https://github.com/SpencerPark/IJava https://dzone.com/articles/apache-zeppelin-stairway-to-notes-haven
  • 21.
    Live Demo • TensorFlowwith Java • DJL • VisRec API 21 Copyright © 2020, Oracle and/or its affiliates | Confidential: Internal/Restricted/Highly Restricted [Date] <dependency> <groupId>org.tensorflow</groupId> <artifactId>tensorflow</artifactId> <version>1.14.0</version> </dependency> Version 2.0 in tensorflow/java Repository, will be merged to Tensorflow/tensorflow repository and documentation will be updated
  • 22.
    ML Deployment andMonitoring with Java API Support 22 https://oracle.github.io/graphpipe, https://github.com/mlflow/mlflow/blob/master/mlflow/java/client/README.md
  • 23.
    ML Deployment -ONNX 23 https://github.com/microsoft/onnxruntime Open Neural Network Exchange - Framework Interoperability - Pretrained ONNX Models (Zoo) - ONNX Tools: Export to ONNX Format - ONNX Tools: Model Optimization - ONNX Runtime Java Support - Microsoft, Facebook, Oracle (Adam) etc
  • 24.
    Java Ecosystem –JSR381 (Visrual Recognition) 24 https://github.com/JavaVisRec/visrec-ri
  • 25.
    25 Audience Poll How wouldyou like learn/hear more in order to succeed ML and Java? 1. YouTube / Video tutorials 2. Blogs, How To Guide etc. 3. Live Training / Live Online Sessions What would you like to learn/hear more about? 1. Cool / Interesting examples (Text, Image, Audio, Video etc.) using ML Frameworks/Toolkits (DL4J, TF-Java, PyTorch-Java, DJL etc.) 2. Cloud Native Java/Jakarta EE ML Use Cases: MLOps(Deployment), Microservices-Kubernetes for ML Services, Deployment and Updates 3. Python based TF, PyTorch Tutorials etc.
  • 26.
    Our mission isto help Java developers succeed with AI, join us and help in whatever way possible.
  • 27.
    Thank You Suyash Joshi suyash@suyashjoshi.com yash.joshi@oracle.com 27 Learningresources: - Twitter @suyashcjoshi @java #ai - Email me and I’ll share more information