SlideShare a Scribd company logo
Bring your neural networks to the
browser with TF.js!
Something about myself
Research fellow @ Sapienza researching on neural
networks
Strong passion for promoting ML in all its aspects
Not-so-easy question:
what is TensorFlow?
TensorFlow is all about:
1. Neural networks
2. Python
3. Huge data & infrastructures
TensorFlow has grown impressively
TensorFlow Distributed Execution Engine
CPU GPU TPU Mobile Embedded
Neural Nets
C++
K-Means
Loss Functions,
Metrics
Linear Algebra Decision Trees SVM
Gaussian
Mixture Models
Regression
Random
Forests
Probabilistic
Methods
Signal
Processing
Lattice
TensorFlow is a comprehensive ML framework
Python Java Javascript
Why Javascript?
1. No installation required
2. Privacy (GDPR, anyone?)
3. Sensors! (Lots of)
4. WebGL
5. The world runs on apps and
web...
Why TF on browsers?
1. Train a model from scratch
2. Fine-tune a model
3. Import a trained model
3 use cases
COMPLEXITY
Bring your neural networks to the browser with TF.js - Simone Scardapane
https://blog.mgechev.com/2018/10/20/transfer-learning-tensorflow-js-data-augmentation-mobile-net/
Bring your neural networks to the browser with TF.js - Simone Scardapane
Interactive visualizations
https://tensorspace.org/
https://github.com/tensorflow/tfjs-vis
TensorFlow.js
Core API (ex deeplearn.js)
TensorFlow
SavedModel
Layers API
Keras
models
Browser (WebGL)
Node.js: everywhere!
(GPUs, TPUs, …)
Inference Time (ms) of MobileNet 1.0_224
Average of 200 runs
Core concepts
Import TF.js in your page
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js" />
<script>
<!-- Code here! -->
...
</script>
</head>
...
</html>
Tensors
// A 3x2 matrix of random numbers
const x = tf.randomUniform([3, 2]);
// Convert from Javascript arrays
const y = tf.tensor1d([0.4, -0.2, 1.0]);
// Matrix operations
const z = x.transpose().matMul(y.reshape([3, 1]));
Auto-differencing
// Function definition
const axis = 1;
const f = x => tf.sin(x).sum(axis);
// Automatic gradient computation
const fGrad = tf.grad(f);
Models and layers
// Initialize the model
const model = tf.sequential();
// Add layers
model.add(tf.layers.dense({'units': 10, 'inputShape': 4}));
model.add(tf.layers.dense({'units': 1}));
// Define loss
const loss = tf.losses.meanSquaredError
// Optimize!
const opt = tf.train.sgd({'lr': 0.1});
opt.minimize(() => loss(model.predict(xs), ys));
Simplified Keras API
model.compile({'optimizer': 'sgd', loss:
'categoricalCrossentropy'});
await model.fit({x: xs, y: ys});
The training step is an async function!
Tidy can help you the code
const sum = tf.tidy(() => {
const a1 = tf.randomUniform([3, 2]);
const a2 = tf.randomNormal([3, 2]);
return a1.square().add(a2);
});
Demo time!
● Input: a (fixed-length) sequence.
● Output: the index of the largest element.
Please don’t do this in real life. :-(
Let’s learn… MAX!
Our RNN
0.14 0.81 0.64 0.0
LSTM
2% 95% 2.5% 0.5%
A better demo
https://magenta.tensorflow.org/js
https://codepen.io/teropa/full/RMGxOQ/
Where to from here?
Some resources
1. TensorFlow.js tutorials:
https://js.tensorflow.org/tutorials/
2. More examples:
https://github.com/tensorflow/tfjs-examples/
Thanks for listening!
«The future will be intensely data-driven. Creating a
dynamic hub that brings together professionals,
industries, and academics will be essential to achieve
this vision.»
http://www.iaml.it/member

More Related Content

What's hot (20)

PDF
Using Multi GPU in PyTorch
Jun Young Park
 
PPTX
Malloc() and calloc() in c
Mahesh Tibrewal
 
PDF
Introduction to Tensor Flow for Optical Character Recognition (OCR)
Vincenzo Santopietro
 
PDF
TensorFlow Dev Summit 2017 요약
Jin Joong Kim
 
PDF
Machine Learning Basics for Web Application Developers
Etsuji Nakai
 
PDF
Introducton to Convolutional Nerural Network with TensorFlow
Etsuji Nakai
 
PDF
Rajat Monga at AI Frontiers: Deep Learning with TensorFlow
AI Frontiers
 
PPTX
Tensor flow
Nikhil Krishna Nair
 
PPTX
Neural networks and google tensor flow
Shannon McCormick
 
PDF
Tensor board
Sung Kim
 
PDF
TensorFlow example for AI Ukraine2016
Andrii Babii
 
PDF
The TensorFlow dance craze
Gabriel Hamilton
 
PPTX
Tensor flow (1)
景逸 王
 
PDF
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
Big Data Spain
 
PPTX
Functions with heap and stack
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
C dynamic ppt
RJ Mehul Gadhiya
 
PPTX
Tensorflow - Intro (2017)
Alessio Tonioni
 
PPTX
16 dynamic-memory-allocation
Rohit Shrivastava
 
PDF
Introduction to TensorFlow, by Machine Learning at Berkeley
Ted Xiao
 
PPTX
Tensorflow windows installation
marwa Ayad Mohamed
 
Using Multi GPU in PyTorch
Jun Young Park
 
Malloc() and calloc() in c
Mahesh Tibrewal
 
Introduction to Tensor Flow for Optical Character Recognition (OCR)
Vincenzo Santopietro
 
TensorFlow Dev Summit 2017 요약
Jin Joong Kim
 
Machine Learning Basics for Web Application Developers
Etsuji Nakai
 
Introducton to Convolutional Nerural Network with TensorFlow
Etsuji Nakai
 
Rajat Monga at AI Frontiers: Deep Learning with TensorFlow
AI Frontiers
 
Tensor flow
Nikhil Krishna Nair
 
Neural networks and google tensor flow
Shannon McCormick
 
Tensor board
Sung Kim
 
TensorFlow example for AI Ukraine2016
Andrii Babii
 
The TensorFlow dance craze
Gabriel Hamilton
 
Tensor flow (1)
景逸 王
 
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
Big Data Spain
 
C dynamic ppt
RJ Mehul Gadhiya
 
Tensorflow - Intro (2017)
Alessio Tonioni
 
16 dynamic-memory-allocation
Rohit Shrivastava
 
Introduction to TensorFlow, by Machine Learning at Berkeley
Ted Xiao
 
Tensorflow windows installation
marwa Ayad Mohamed
 

Similar to Bring your neural networks to the browser with TF.js - Simone Scardapane (20)

PDF
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
OdessaFrontend
 
PDF
Introduction to Neural Networks in Tensorflow
Nicholas McClure
 
PDF
Introduction to Tensorflow.js
Riza Fahmi
 
PPTX
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Simplilearn
 
PPTX
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
Simplilearn
 
PPTX
TensorFlow for IITians
Ashish Bansal
 
PDF
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
PPTX
Keras on tensorflow in R & Python
Longhow Lam
 
PDF
Introduction to TensorFlow 2.0
Databricks
 
PDF
TensorFlow and Keras: An Overview
Poo Kuan Hoong
 
PDF
Google Big Data Expo
BigDataExpo
 
PPTX
Machine Learning - Introduction to Tensorflow
Andrew Ferlitsch
 
PPTX
H2 o berkeleydltf
Oswald Campesato
 
PDF
Neural networks using tensor flow in amazon deep learning server
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
PDF
TF Dev Summit 2019
Ray Hilton
 
PPTX
Tensorflow Ecosystem
Vivek Raja P S
 
PPTX
Deep Learning, Keras, and TensorFlow
Oswald Campesato
 
PDF
Tensorflow 2 Pocket Reference Building And Deploying Machine Learning Models ...
tmnfxlrqd1983
 
PDF
Google TensorFlow Tutorial
台灣資料科學年會
 
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
OdessaFrontend
 
Introduction to Neural Networks in Tensorflow
Nicholas McClure
 
Introduction to Tensorflow.js
Riza Fahmi
 
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Simplilearn
 
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
Simplilearn
 
TensorFlow for IITians
Ashish Bansal
 
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
Keras on tensorflow in R & Python
Longhow Lam
 
Introduction to TensorFlow 2.0
Databricks
 
TensorFlow and Keras: An Overview
Poo Kuan Hoong
 
Google Big Data Expo
BigDataExpo
 
Machine Learning - Introduction to Tensorflow
Andrew Ferlitsch
 
H2 o berkeleydltf
Oswald Campesato
 
Neural networks using tensor flow in amazon deep learning server
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
TF Dev Summit 2019
Ray Hilton
 
Tensorflow Ecosystem
Vivek Raja P S
 
Deep Learning, Keras, and TensorFlow
Oswald Campesato
 
Tensorflow 2 Pocket Reference Building And Deploying Machine Learning Models ...
tmnfxlrqd1983
 
Google TensorFlow Tutorial
台灣資料科學年會
 
Ad

More from MeetupDataScienceRoma (20)

PDF
Serve Davvero il Machine Learning nelle PMI? | Niccolò Annino
MeetupDataScienceRoma
 
PDF
Meta-learning through the lenses of Statistical Learning Theory (Carlo Cilibe...
MeetupDataScienceRoma
 
PPTX
Claudio Gallicchio - Deep Reservoir Computing for Structured Data
MeetupDataScienceRoma
 
PDF
Docker for Deep Learning (Andrea Panizza)
MeetupDataScienceRoma
 
PDF
Machine Learning for Epidemiological Models (Enrico Meloni)
MeetupDataScienceRoma
 
PDF
Quantum Machine Learning and QEM for Gaussian mixture models (Alessandro Luongo)
MeetupDataScienceRoma
 
PDF
Web Meetup #2: Modelli matematici per l'epidemiologia
MeetupDataScienceRoma
 
PDF
Deep red - The environmental impact of deep learning (Paolo Caressa)
MeetupDataScienceRoma
 
PDF
[Sponsored] C3.ai description
MeetupDataScienceRoma
 
PDF
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
MeetupDataScienceRoma
 
PPTX
Multimodal AI Approach to Provide Assistive Services (Francesco Puja)
MeetupDataScienceRoma
 
PPTX
Introduzione - Meetup MLOps & Assistive AI
MeetupDataScienceRoma
 
PDF
Zero, One, Many - Machine Learning in Produzione (Luca Palmieri)
MeetupDataScienceRoma
 
PPTX
Mario Incarnati - The power of data visualization
MeetupDataScienceRoma
 
PDF
Machine Learning in the AWS Cloud
MeetupDataScienceRoma
 
PPTX
OLIVAW: reaching superhuman strength at Othello
MeetupDataScienceRoma
 
PDF
[Giovanni Galloro] How to use machine learning on Google Cloud Platform
MeetupDataScienceRoma
 
PPTX
Meetup Gennaio 2019 - Slide introduttiva
MeetupDataScienceRoma
 
PPTX
Elena Gagliardoni - Neural Chatbot
MeetupDataScienceRoma
 
PDF
Bruno Coletta - Data-Driven Creativity in Marketing and Advertising
MeetupDataScienceRoma
 
Serve Davvero il Machine Learning nelle PMI? | Niccolò Annino
MeetupDataScienceRoma
 
Meta-learning through the lenses of Statistical Learning Theory (Carlo Cilibe...
MeetupDataScienceRoma
 
Claudio Gallicchio - Deep Reservoir Computing for Structured Data
MeetupDataScienceRoma
 
Docker for Deep Learning (Andrea Panizza)
MeetupDataScienceRoma
 
Machine Learning for Epidemiological Models (Enrico Meloni)
MeetupDataScienceRoma
 
Quantum Machine Learning and QEM for Gaussian mixture models (Alessandro Luongo)
MeetupDataScienceRoma
 
Web Meetup #2: Modelli matematici per l'epidemiologia
MeetupDataScienceRoma
 
Deep red - The environmental impact of deep learning (Paolo Caressa)
MeetupDataScienceRoma
 
[Sponsored] C3.ai description
MeetupDataScienceRoma
 
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
MeetupDataScienceRoma
 
Multimodal AI Approach to Provide Assistive Services (Francesco Puja)
MeetupDataScienceRoma
 
Introduzione - Meetup MLOps & Assistive AI
MeetupDataScienceRoma
 
Zero, One, Many - Machine Learning in Produzione (Luca Palmieri)
MeetupDataScienceRoma
 
Mario Incarnati - The power of data visualization
MeetupDataScienceRoma
 
Machine Learning in the AWS Cloud
MeetupDataScienceRoma
 
OLIVAW: reaching superhuman strength at Othello
MeetupDataScienceRoma
 
[Giovanni Galloro] How to use machine learning on Google Cloud Platform
MeetupDataScienceRoma
 
Meetup Gennaio 2019 - Slide introduttiva
MeetupDataScienceRoma
 
Elena Gagliardoni - Neural Chatbot
MeetupDataScienceRoma
 
Bruno Coletta - Data-Driven Creativity in Marketing and Advertising
MeetupDataScienceRoma
 
Ad

Recently uploaded (20)

PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 

Bring your neural networks to the browser with TF.js - Simone Scardapane