machine learning with java? deeplearning4j! · train model evaluate the model export the model....
TRANSCRIPT
![Page 1: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/1.jpg)
Machine Learning with Java? Deeplearning4j!
Enrique Llerena DominguezJava Forum Stuttgart 2020
![Page 2: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/2.jpg)
$whoami
• Enrique Llerena Dominguez• Senior Software Engineer / Consultant @
mimacom• Experience developing software for the finance,
retail, pharma, and automotive industry
• Professional Interests: Software Architecture, Cloud Computing, Artificial Intelligence
• Free Time: Spending time with my kids, watchingfootball, learning german, and developing nicethings
![Page 5: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/5.jpg)
![Page 6: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/6.jpg)
Image source: Photo by dylan nolte on Unsplash
![Page 7: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/7.jpg)
Agenda
• Machine Learning 101 + deeplearning4j
• Deeplearning4j integrations
• Hands on examples:• Image classification – Approach and code• Sentiment analysis – Approach and code
![Page 8: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/8.jpg)
What is Machine Learning?
• Machine Learning is the study of computer algorithms that improve automatically through experience
Source: Mitchell, T. (1997), Machine Learning. http://www.cs.cmu.edu/~tom/mlbook.html , retrieved 08.2020
![Page 9: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/9.jpg)
What is Machine Learning?
![Page 10: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/10.jpg)
What is Deeplearning4j?
Open-source deep-learning library written for Java and Scala
![Page 11: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/11.jpg)
Story time!
Iris classification AKA the “Machine Learning Hello World”
![Page 12: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/12.jpg)
Image source: Photo by Alex on Unsplash
Peter the biologist
![Page 13: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/13.jpg)
Image source: https://en.wikipedia.org/wiki/Gasp%C3%A9_Peninsula
![Page 14: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/14.jpg)
Images source:https://en.wikipedia.org/wiki/Iris_flower_data_set
![Page 15: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/15.jpg)
Images source: https://en.wikipedia.org/wiki/Iris_flower_data_set
Iris Setosa
Iris Versicolor
Iris Virginica
![Page 16: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/16.jpg)
Image source: Photo by Blaz Erzetic on Unsplash
![Page 17: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/17.jpg)
Images source: Photo by Ben Mullins on Unsplash
![Page 18: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/18.jpg)
Images source:Photo by Jarritos Mexican Soda on Unsplash
![Page 19: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/19.jpg)
Image source: Photo by Alex on Unsplash
it would be really cool that someone else could classify this flower just by providing the measurements!
![Page 20: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/20.jpg)
Photo by Jarritos Mexican Soda on Unsplash
Teresa the software engineer, Peter’s daughter
![Page 21: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/21.jpg)
Photo by Jarritos Mexican Soda on Unsplash
hey! I can automate that!
![Page 22: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/22.jpg)
Photo by Jarritos Mexican Soda on Unsplash
But first things first
![Page 23: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/23.jpg)
Photo by NESA by Makers on Unsplash
![Page 24: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/24.jpg)
Images sources: Photo by Ben Mullins on Unsplash
Deeplearning4j Logo https://github.com/eclipse/deeplearning4j Java Logo, By Source (WP:NFCC#4), Fair use, https://en.wikipedia.org/w/index.php?curid=51298819
Maven Logo, By Apache Software Foundation - Apache Software Foundationhttp://maven.apache.org/images/maventxt_logo_200.gif, Attribution,
https://commons.wikimedia.org/w/index.php?curid=10365467
Labeled dataset
Resources
![Page 25: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/25.jpg)
Problem description
• Type: Classification• Dataset:• Number of instances: 150• Number of attributes: 4
• sepal length in cm• sepal width in cm• petal length in cm• petal width in cm
• Number of classes: 3• Iris Setosa• Iris Versicolour• Iris Virginica
Source: University of California, Irvine , Iris Data Set. https://archive.ics.uci.edu/ml/datasets/iris , retrieved 08.2020
![Page 26: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/26.jpg)
![Page 27: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/27.jpg)
Training step
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model
Train model
Evaluate the model
Export the model
![Page 28: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/28.jpg)
Iris Classifier Trainer Most Valuable Code
![Page 29: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/29.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 30: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/30.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 31: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/31.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 32: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/32.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 33: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/33.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 34: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/34.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 35: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/35.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 36: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/36.jpg)
sepal length sepal width petal length petal width5,10 3,50 1,40 0,20
TypesIris SetosaIris VirginicaIris Versicolor
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 37: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/37.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 38: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/38.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 39: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/39.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 40: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/40.jpg)
Load the dataset
Normalize the data
Split in train and test datasets
Configure the model Train model Evaluate the
modelExport the
model
![Page 41: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/41.jpg)
Prediction step
Load the model
Format the data
Normalize the data
Feed the data
Get the label
![Page 42: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/42.jpg)
Iris Classifier Predictor Most Valuable Code
![Page 43: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/43.jpg)
Load the model
Format the data
Normalize the data
Feed the data
Get the label
![Page 44: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/44.jpg)
Load the model
Format the data
Normalize the data
Feed the data
Get the label
![Page 45: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/45.jpg)
Load the model
Format the data
Normalize the data
Feed the data
Get the label
![Page 46: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/46.jpg)
Load the model
Format the data
Normalize the data
Feed the data
Get the label
![Page 47: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/47.jpg)
Load the model
Format the data
Normalize the data
Feed the data
Get the label
![Page 48: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/48.jpg)
![Page 49: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/49.jpg)
Peter is happy!
Now my friends can classify these flowers just by calling the FlowerClassification API with the measurements! :D
![Page 50: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/50.jpg)
What did we learn?
• 2 main steps• Training
• Input: Labeled dataset• Output: Trained model
• Prediction• Input: Trained model + unlabeled data• Output: Prediction -> in this case, of type “classification”
• How to use Deeplearning4j to train a model, export it, load it and perform a prediction
![Page 51: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/51.jpg)
Machine Learning Approaches
• Supervised• Classification• Regression
• Unsupervised
• Reinforcement learning
Source: Wikipedia, Machine Learning. https://en.wikipedia.org/wiki/Machine_learning , retrieved 08.2020
![Page 52: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/52.jpg)
Machine Learning Approaches
• Supervised• Classification• Regression
• Unsupervised
• Reinforcement learning
![Page 53: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/53.jpg)
Machine Learning Algorithms
• Examples:• Support Vector Machines• Linear regression• Logistic regression• Naive Bayes• Linear discriminant analysis• Decision trees• Neural Networks (Multilayer perceptron)• …
Source: Wikipedia, Machine Learning. https://en.wikipedia.org/wiki/Machine_learning , retrieved 08.2020
![Page 54: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/54.jpg)
Deeplearning4j integrations
Images sourcesApache Spark logo, https://spark.apache.org/images/spark-logo-trademark.pngApache Hadoop logo, https://hadoop.apache.org/hadoop-logo.jpg
Distributed training
![Page 55: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/55.jpg)
Deeplearning4j integrations
Images source: Keras logo, https://keras.io/img/logo.pngNivida CUDA logo, https://en.wikipedia.org/w/index.php?curid=53650345
Parallel training
Import models
![Page 56: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/56.jpg)
Deeplearning4j integrations
source: Keras logo, https://keras.io/img/logo.pngKeras description, Keras, https://en.wikipedia.org/wiki/Keras , retrieved 08/2020
Keras is an open-source neural-network library written in Python. It is capable of running on top of TensorFlow, Microsoft Cognitive Toolkit, R, Theano, or PlaidML.
![Page 57: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/57.jpg)
One step back
![Page 58: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/58.jpg)
Decoupled in time!
![Page 59: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/59.jpg)
* JVM Language
![Page 60: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/60.jpg)
+
=Flexibility
![Page 61: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/61.jpg)
![Page 62: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/62.jpg)
Deeplearning4j integrations
+
=Flexibility
• Enables the integration of people with different technical profiles• Opens the door to more pretrained models
![Page 63: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/63.jpg)
Image Classification
• Approach:• Deeplearning4j’s Model Zoo• OpenCV
![Page 64: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/64.jpg)
Deeplearning4j’s Model Zoo
![Page 65: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/65.jpg)
Image sourceYolo Logo , https://pjreddie.com/media/image/yologo_2.png
![Page 66: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/66.jpg)
Image sourceYolo Example , https://pjreddie.com/media/image/Screen_Shot_2018-03-24_at_10.48.42_PM.png
![Page 67: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/67.jpg)
person fire hydrant elephant skis wine glass broccoli diningtable toaster
bicycle stop sign bear snowboard cup carrot toilet sink
car parking meter zebra sports ball fork hot dog tvmonitor refrigerator
motorbike bench giraffe kite knife pizza laptop book
aeroplane bird backpack baseball bat spoon donut mouse clock
bus cat umbrella baseball glove bowl cake remote vase
train dog handbag skateboard banana chair keyboard scissors
truck horse tie surfboard apple sofa cell phone teddy bear
boat sheep suitcase tennis racket sandwich pottedplant microwave hair drier
traffic light cow frisbee bottle orange bed oven toothbrush
YOLOv2 Available Labels
![Page 68: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/68.jpg)
Load model from Zoo Load image Preprocess
imageFeed the
model
Get detected objects
Annotate original image
Steps overview
![Page 69: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/69.jpg)
Yolo2ImageClassifier - Most Valuable Code
![Page 70: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/70.jpg)
![Page 71: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/71.jpg)
Image source: unsplash. Annotated by myself using yolo2
![Page 72: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/72.jpg)
Image source: unsplash. Annotated by myself using yolo2
![Page 73: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/73.jpg)
Image source: unsplash. Annotated by myself using yolo2
![Page 74: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/74.jpg)
Image source: unsplash. Annotated by myself using yolo2
![Page 75: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/75.jpg)
Image source: unsplash. Annotated by myself using yolo2
![Page 76: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/76.jpg)
Image source: Deeplearning4j Animal Classification Dataset. Annotated by myself using yolo2
![Page 77: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/77.jpg)
Image source: Deeplearning4j Animal Classification Dataset. Annotated by myself using yolo2
![Page 78: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/78.jpg)
Sentiment Analysis
• Approach:• Take an example and modify it
• deeplearning4j.examples - ImdbReviewClassificationCNN.java
• Get a new dataset from https://www.kaggle.com/kazanova/sentiment140
![Page 79: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/79.jpg)
![Page 80: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/80.jpg)
![Page 81: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/81.jpg)
Overview
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 82: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/82.jpg)
Goal:Transform the words into vectors (numbers) that the model can understand
Word2Vec
• Two-layer neural network• Input: a corpus of text• Output: a vector space• Each unique word in the corpus is assigned a corresponding vector in the space
Vectorizing words
Source: Wikipedia, Word2vec, https://en.wikipedia.org/wiki/Word2vec , retrieved 08.2020
![Page 83: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/83.jpg)
Vectorizing words
![Page 84: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/84.jpg)
Sentiment Analysis – Most Valuable Code
![Page 85: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/85.jpg)
• This is loading a trained Word2Vec model from Google, can be downloaded fromhttps://dl4jdata.blob.core.windows.net/resources/wordvectors/GoogleNews-vectors-negative300.bin.gz
• Example to train your own word2vec model at SimpleExampleWord2Vec.java at https://github.com/ellerenad/deeplearning4j-playground
Goal:Transform the words into vectors (numbers) that the model can understand
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 86: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/86.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 87: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/87.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 88: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/88.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 89: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/89.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 90: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/90.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 91: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/91.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 92: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/92.jpg)
Configure the model
![Page 93: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/93.jpg)
Vectorizing words
![Page 94: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/94.jpg)
Configure the model
![Page 95: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/95.jpg)
Load the word
vectorizer
Load the dataset
Clean the dataset
Vectorize the words
Configure the model
Train the model
Evaluate the model
Export the model
![Page 96: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/96.jpg)
Sentiment analysis prediction example
“this code is driving me crazy! what was this guy thinking!? *Annotates the code* oh... it was me”
P(Negative) = 0.72P(Positive) = 0.28
Label: Negative
![Page 97: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/97.jpg)
Problems during development
• Slow feedback• Memory management• Loading the dataset
![Page 98: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/98.jpg)
Sampling for faster feedback
![Page 99: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/99.jpg)
Comparing results
Accuracy 0.7472Precision 0.7200Recall 0.8065F1 Score 0.7608
Execution Time 1581209 ms~26.3 min
Samples: 800000
Accuracy 0.6721Precision 0.6382Recall 0.7886F1 Score 0.7055
Execution Time 165002 ms ~2.75 min
Samples: 2000
10x
40x
![Page 100: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/100.jpg)
Comparing results
Loading the word vectors: 154804 ms~2.58 min
Accuracy 0.6721Precision 0.6382Recall 0.7886F1 Score 0.7055
Execution Time 165002 ms ~2.75 min
Samples: 2000
![Page 101: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/101.jpg)
Memory Management
• Tweak the JVM with the params:
More details at: https://deeplearning4j.konduit.ai/config/config-memory
![Page 102: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/102.jpg)
On files bigger than 40,000 lines, the java.util.Scanner would read just up to the half of the file, messing with the training.
Load the data set
![Page 103: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/103.jpg)
Image source: Photo by dylan nolte on Unsplash
![Page 104: Machine Learning with Java? Deeplearning4j! · Train model Evaluate the model Export the model. Iris Classifier Trainer Most Valuable Code. Load the dataset Normalize the data Split](https://reader033.vdocument.in/reader033/viewer/2022051812/602e41197fd3de149b0bc31e/html5/thumbnails/104.jpg)
Thanks! Questions?
All the code can be found athttps://github.com/ellerenad/deeplearning4j-playground
Enrique Llerena Dominguez
Twitter @ellerenad
Github @ellerenad
Quiz for the raffle!