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

PPTX
Simone Scardapane - Bring your neural networks to the browser with TF.js! - C...
PPTX
Unity best practices (2013)
ODP
Neuronvisio sumatra workflow
PDF
Your first TensorFlow programming with Jupyter
PPTX
Practical Reinforcement Learning with TensorFlow
PPTX
Introduction to Machine Learning with TensorFlow
PDF
Machine Intelligence at Google Scale: TensorFlow
PDF
Learning stochastic neural networks with Chainer
Simone Scardapane - Bring your neural networks to the browser with TF.js! - C...
Unity best practices (2013)
Neuronvisio sumatra workflow
Your first TensorFlow programming with Jupyter
Practical Reinforcement Learning with TensorFlow
Introduction to Machine Learning with TensorFlow
Machine Intelligence at Google Scale: TensorFlow
Learning stochastic neural networks with Chainer

What's hot (20)

PDF
Using Multi GPU in PyTorch
PPTX
Malloc() and calloc() in c
PDF
Introduction to Tensor Flow for Optical Character Recognition (OCR)
PDF
TensorFlow Dev Summit 2017 요약
PDF
Machine Learning Basics for Web Application Developers
PDF
Introducton to Convolutional Nerural Network with TensorFlow
PDF
Rajat Monga at AI Frontiers: Deep Learning with TensorFlow
PPTX
Tensor flow
PPTX
Neural networks and google tensor flow
PDF
Tensor board
PDF
TensorFlow example for AI Ukraine2016
PDF
The TensorFlow dance craze
PPTX
Tensor flow (1)
PDF
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
PPTX
PPTX
C dynamic ppt
PPTX
Tensorflow - Intro (2017)
PPTX
16 dynamic-memory-allocation
PDF
Introduction to TensorFlow, by Machine Learning at Berkeley
PPTX
Tensorflow windows installation
Using Multi GPU in PyTorch
Malloc() and calloc() in c
Introduction to Tensor Flow for Optical Character Recognition (OCR)
TensorFlow Dev Summit 2017 요약
Machine Learning Basics for Web Application Developers
Introducton to Convolutional Nerural Network with TensorFlow
Rajat Monga at AI Frontiers: Deep Learning with TensorFlow
Tensor flow
Neural networks and google tensor flow
Tensor board
TensorFlow example for AI Ukraine2016
The TensorFlow dance craze
Tensor flow (1)
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
C dynamic ppt
Tensorflow - Intro (2017)
16 dynamic-memory-allocation
Introduction to TensorFlow, by Machine Learning at Berkeley
Tensorflow windows installation
Ad

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

PDF
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
PDF
Introduction to Neural Networks in Tensorflow
PDF
Introduction to Tensorflow.js
PPTX
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
PPTX
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
PPTX
TensorFlow for IITians
PDF
Tensorflow 2.0 and Coral Edge TPU
PPTX
Keras on tensorflow in R & Python
PDF
Introduction to TensorFlow 2.0
PDF
TensorFlow and Keras: An Overview
PDF
Google Big Data Expo
PPTX
Machine Learning - Introduction to Tensorflow
PPTX
H2 o berkeleydltf
PDF
Neural networks using tensor flow in amazon deep learning server
PDF
TF Dev Summit 2019
PPTX
Tensorflow Ecosystem
PPTX
Deep Learning, Keras, and TensorFlow
PDF
Tensorflow 2 Pocket Reference Building And Deploying Machine Learning Models ...
PDF
Google TensorFlow Tutorial
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Introduction to Neural Networks in Tensorflow
Introduction to Tensorflow.js
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
TensorFlow for IITians
Tensorflow 2.0 and Coral Edge TPU
Keras on tensorflow in R & Python
Introduction to TensorFlow 2.0
TensorFlow and Keras: An Overview
Google Big Data Expo
Machine Learning - Introduction to Tensorflow
H2 o berkeleydltf
Neural networks using tensor flow in amazon deep learning server
TF Dev Summit 2019
Tensorflow Ecosystem
Deep Learning, Keras, and TensorFlow
Tensorflow 2 Pocket Reference Building And Deploying Machine Learning Models ...
Google TensorFlow Tutorial
Ad

More from MeetupDataScienceRoma (20)

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

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Modernizing your data center with Dell and AMD
PDF
Machine learning based COVID-19 study performance prediction
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
Modernizing your data center with Dell and AMD
Machine learning based COVID-19 study performance prediction
“AI and Expert System Decision Support & Business Intelligence Systems”
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication

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