Successfully reported this slideshow.
Your SlideShare is downloading. ×

A Look at TensorFlow.js

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 49 Ad

A Look at TensorFlow.js

TensforFlow.js is a WebGL accelerated, browser based JavaScript library for training and deploying ML models. We will take a look at this library and how it can be used to train and run deep learning models in the browser.

During this talk we will go through the basics of Deep Learning and TensforFlow.js and how we can use it to create artificial neural networks, train and run existing models in the browser.

Speaker: Jamal O'Garro

I'm a former finance guy on the business side turned finance guy on the tech side that also loves entrepreneurship and NYC startup culture. I'm a huge fan of full-stack web development with JavaScript and enjoy building software with AngularJS and Node.js as well as building native iOS apps. In my spare time I like to write and backtest simple algo trading strategies in Python, attend hackathons, give tech talks and teach others how to code. In my spare spare time (whenever that is) I like to read, blog, write songs,shoot street photography and make documentary films. I love to create and my motto is simply, "THINK IT, BELIEVE IT, CREATE IT!"

TensforFlow.js is a WebGL accelerated, browser based JavaScript library for training and deploying ML models. We will take a look at this library and how it can be used to train and run deep learning models in the browser.

During this talk we will go through the basics of Deep Learning and TensforFlow.js and how we can use it to create artificial neural networks, train and run existing models in the browser.

Speaker: Jamal O'Garro

I'm a former finance guy on the business side turned finance guy on the tech side that also loves entrepreneurship and NYC startup culture. I'm a huge fan of full-stack web development with JavaScript and enjoy building software with AngularJS and Node.js as well as building native iOS apps. In my spare time I like to write and backtest simple algo trading strategies in Python, attend hackathons, give tech talks and teach others how to code. In my spare spare time (whenever that is) I like to read, blog, write songs,shoot street photography and make documentary films. I love to create and my motto is simply, "THINK IT, BELIEVE IT, CREATE IT!"

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to A Look at TensorFlow.js (20)

Advertisement

Recently uploaded (20)

Advertisement

A Look at TensorFlow.js

  1. 1. A LOOK AT TENSORFLOW.JS Jamal O’Garro Software Engineer MEAN STACK NYC | MAY 17, 2018
  2. 2. • Full-stack web-developer based in NYC • Professional Languages: JavaScript, Node, React, D3, TypeScript, Python • Hobby languages: Haskell, Golang • Mostly self-taught • Native New Yorker • Sneakerhead + Hip Hop Head • True Knicks fan MEAN STACK NYC | MAY 17, 2018 BIO
  3. 3. • High level overview of deep learning and neural networks • Look at the TensorFlow.js API • Look at some examples provided by Google TODAY’S AGENDA MEAN STACK NYC | MAY 17, 2018
  4. 4. • Comfortable with JavaScript • Familiar with ES6/ES7/ES8 syntax • Not going to assume you will get all of the theory (very little math!) ASSUMPTIONS MEAN STACK NYC | MAY 17, 2018
  5. 5. MACHINE & DEEP LEARNING MEAN STACK NYC | MAY 17, 2018
  6. 6. “Artificial intelligence (AI, also machine intelligence, MI) intelligence demonstrated by machines, in contrast to the natural intelligence (NI) displayed by humans and other animals. ” - Wikipedia WHAT IS ARTIFICIAL INTELLIGENCE? MEAN STACK NYC | MAY 17, 2018
  7. 7. “Machine learning is a field of computer science that uses statistical techniques to give computer systems the ability to "learn" (e.g., progressively improve performance on a specific task) with data, without being explicitly programmed.” - Wikipedia WHAT IS MACHINE LEARNING? MEAN STACK NYC | MAY 17, 2018
  8. 8. “Deep Learning is a subfield of machine learning concerned with algorithms inspired by the structure and function of the brain called artificial neural networks.” - Jason Brownlee, Machine Learning Mastery WHAT IS DEEP LEARNING? MEAN STACK NYC | MAY 17, 2018
  9. 9. • Facebook Face Recognition • Amazon product recommendations • Netflix movie recommendations • Spotify music recommendations • Uber estimated time of arrival • Predicting stock price movements EXAMPLES OF ML IN THE WILD MEAN STACK NYC | MAY 17, 2018
  10. 10. • Supervised Learning - learn how to classify or predict a value based on previous observations • Unsupervised Learning - find a pattern from existing data • Reinforcement Learning - provide positive or negative feedback based on expected outcome TYPES OF LEARNING MEAN STACK NYC | MAY 17, 2018
  11. 11. NEURAL NETWORKS MEAN STACK NYC | MAY 17, 2018
  12. 12. “Artificial neural networks (ANNs) or connectionist systems are computing systems vaguely inspired by the biological neural networks that constitute animal brains. Such systems "learn" (i.e. progressively improve performance on) tasks by considering examples, generally without task-specific programming.”  - Wikipedia WHAT IS A NEURAL NETWORK? MEAN STACK NYC | MAY 17, 2018
  13. 13. • Dendrite - receives signals from another neuron • Neuron - processes the signal • Axon - transmits signals to another neuron BIOLOGICAL NEURAL NETWORK MEAN STACK NYC | MAY 17, 2018
  14. 14. HUMAN NEURON DIAGRAM MEAN STACK NYC | MAY 17, 2018 - Wikipedia
  15. 15. • Input layers - layer that contains our data that we want to learn from • Hidden layers - layers that sit between the input and output layers (process data and return and output) • Output layer - final output or estimate NEURAL NETWORK COMPONENTS MEAN STACK NYC | MAY 17, 2018
  16. 16. NEURAL NETWORK DIAGRAM MEAN STACK NYC | MAY 17, 2018 - Wikipedia
  17. 17. • Allow us to normalize our data • Sigmoid - normalizes value between 0 and 1 • ReLU - returns max of 0 and a value • tanh - normalizes value to between -1 and 1 ACTIVATION FUNCTIONS MEAN STACK NYC | MAY 17, 2018
  18. 18. ACTIVATION FUNCTIONS - SIGMOID MEAN STACK NYC | MAY 17, 2018 - www.towardsdatascience.com
  19. 19. ACTIVATION FUNCTIONS - ReLU MEAN STACK NYC | MAY 17, 2018 - www.towardsdatascience.com
  20. 20. ACTIVATION FUNCTIONS - tanh MEAN STACK NYC | MAY 17, 2018 - www.towardsdatascience.com
  21. 21. • Allow us to evaluate the performance of our model (how far off are our predictions from the actual observations) • Mean Squared Error - good choice for regression problems • Cross Entropy - good choice for classification problems COST FUNCTIONS MEAN STACK NYC | MAY 17, 2018
  22. 22. COST FUNCTIONS - MEAN SQUARED ERROR MEAN STACK NYC | MAY 17, 2018 - Wikipedia
  23. 23. COST FUNCTIONS - CROSS ENTROPY MEAN STACK NYC | MAY 17, 2018 - Wikipedia
  24. 24. TRAINING MEAN STACK NYC | MAY 17, 2018 • The process of minimizing the errors between our predictions and our observations • Minimizing our cost function
  25. 25. GRADIENT DESCENT MEAN STACK NYC | MAY 17, 2018 • Algorithm that allows us to find the minimum of a function • Take a guess along a curve or surface and take steps in the negative direction until we find a global minimum (i.e. dy/dx = 0) • Learning Rate - size of the steps we take when searching for our global minimum
  26. 26. GRADIENT DESCENT DIAGRAM MEAN STACK NYC | MAY 17, 2018 - Wikipedia
  27. 27. BACK PROPAGATION MEAN STACK NYC | MAY 17, 2018 • Calculates how much each predicted value contributes to an error • When we have an error we adjust the weights, biases, etc. of our neurons to reduce it (i.e. minimize the cost)
  28. 28. TENSORFLOW MEAN STACK NYC | MAY 17, 2018
  29. 29. WHAT IS TENSORFLOW? • Numerical computation library developed and open sourced by Google • Runs on CPU/GPU across clusters and sessions • Data flows through Tensors • Can create models and deploy to different production systems (Web, Mobile apps, etc.) • Written in C++ MEAN STACK NYC | MAY 17, 2018
  30. 30. TENSORFLOW ECOSYSTEM MEAN STACK NYC | MAY 17, 2018
  31. 31. TENSORFLOW.JS ECOSYSTEM MEAN STACK NYC | MAY 17, 2018
  32. 32. TENSORFLOW.JS • Originally was deeplearning.js • Two APIs (Core + Layers) • Can build new models and retrain existing ones • Ability to load existing models for inference • Uses the computer’s GPU for both training and inference • Browser ready with active development on Node bindings MEAN STACK NYC | MAY 17, 2018
  33. 33. • Tensor • Variable • Session • Layer • Model TENSORFLOW.JS TERMINOLOGY MEAN STACK NYC | MAY 17, 2018
  34. 34. CORE API • Low-level operations • Linear Algebra transformations • Written in pure JavaScript • Targets the GPU via WebGL MEAN STACK NYC | MAY 17, 2018
  35. 35. CORE API - TENSORS • Immutable data in our program • Scalar • Vector • Matrix MEAN STACK NYC | MAY 17, 2018
  36. 36. CORE API - VARIABLES • Mutable data that can be reassigned during the life of our program MEAN STACK NYC | MAY 17, 2018
  37. 37. CORE API - OPERATIONS • Allows us to manipulate our data • tf.add - adds two tensors • tf.sub - subtracts two tensors • tf.mul - multiplies two tensors • tf.div - divides two tensors • tf.maximum - returns the max of two tensors • tf.minimum - returns the min of two tensors MEAN STACK NYC | MAY 17, 2018
  38. 38. CORE API MEAN STACK NYC | MAY 17, 2018
  39. 39. LAYERS API • Inspired by Keras • Built on top of the Core API • High-level abstractions of neural network constructs MEAN STACK NYC | MAY 17, 2018
  40. 40. LAYERS API - MODEL • A function when given some input will produce and output • tf.Model - basic unit of training • tf.Sequential - a model with a stack of layers feeding from one layer to the next MEAN STACK NYC | MAY 17, 2018
  41. 41. LAYERS API - LAYER • Primary building block for building a model. Performs transformation to convert an input into an output. • tf.layers.activation - applies an activation function to a layer • tf.layers.dense - creates a fully connected layer • tf.layers.flatten - flattens input to one dimension • tf.layers.reshape - reshapes an input to a specified shape MEAN STACK NYC | MAY 17, 2018
  42. 42. LAYERS API - CONFIG • Loss - the model’s loss function • Optimizer - algorithm that minimizes the error of our model • Metrics - list of metrics to be evaluated MEAN STACK NYC | MAY 17, 2018
  43. 43. LAYERS API MEAN STACK NYC | MAY 17, 2018
  44. 44. MEMORY MANAGEMENT • Must manage memory on the GPU when working with Tensors and variables • Easy to create memory leaks if you’re not careful • Tensor.dispose - disposes of a tensor • tf.tidy - provides a scope for us to run our program in and cleans up any tensors created during the process • Should be a synchronous function • Does not clean up variables (must dispose manually) • tf.keep - prevents a tensor created within a “tidy” block from being disposed MEAN STACK NYC | MAY 17, 2018
  45. 45. • Can train new and retrain existing models in the browser • Can use existing models for inference in the browser • Soon we’ll be able to do this in Node! WHY IS THIS AWESOME? MEAN STACK NYC | MAY 17, 2018
  46. 46. LET’S BUILD A BRAIN! MEAN STACK NYC | MAY 17, 2018
  47. 47. RESOURCES MEAN STACK NYC | MAY 17, 2018
  48. 48. RESOURCES Documentation • js.tensorflow.org • TensorFlow.js Github Repository • Google Developers Deep Learning Glossary Books • Deep Learning with Python - Francois Chollet • Learning from Data - Yaser S. Abu-Mostafa • Neural Networks and Deep Learning - Michael Nielsen Courses • Google's Deep Learning Crash Course • deeplearning.ai Tools • TensorFlow Playground Datasets • Kaggle MEAN STACK NYC | MAY 17, 2018
  49. 49. THANK YOU!!! Jamal O’Garro Software Engineer + Instructor MEAN STACK NYC | MAY 17, 2018

×