Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Can we play Machine Learning in Frontend?

Can we play Machine Learning in Frontend?

Wei-Ting Wang

October 02, 2019
Tweet

Transcript

  1. – Nvidia “Machine Learning at its most basic is the

    practice of using algorithms to parse data, Learn from it, and then make a Determination or Prediction about something in the world”
  2. Training Data f Predicts ① dog ② cat ③ dog

    ④ dog ⑤ rabbit ⑥ cat … Labels ① dog ② dog ③ dog ④ cat ⑤ rabbit ⑥ cat … Compare Feedback then modify function Training Model X X Model
  3. To be simple • A set of pairs • •

    What are “ ” and “ ”? (xi , yj ) y = f(x) = wx + b w b y x X x1, x2, x3, …, xn Y y1, y2, y3, …, yn How to find the best fit function?
  4. To be simple • A set of pairs • •

    What are “ ” and “ ”? (xi , yj ) y = f(x) = wx + b w b X x1, x2, x3, …, xn Y y1, y2, y3, …, yn y x How to find the best fit function?
  5. To be simple • The Method of Least Square •

    Calculate Mean Square Error MSE = 1 n n ∑ i=1 (yreal − ypredict )2 = 1 n n ∑ i=1 (yi − (wxi + b))2 MSE w ∂MSE(w) ∂w = 0 How to find the extreme value
  6. To be general • Loss Function • Optimizer Function L(wi

    ) L′(wi ) = ∂L ∂wi L wi ∂L ∂wi = 0 How to find the extreme value
  7. z = m ∑ i=1 wi xi + b a2

    1 X2 b1 X1 a2 1 = σ(z2 1 ) = σ(w2 11 x1 + w2 12 x2 + b2 1 )
  8. Python - the star in ML • SKlearn • TensorFlow

    • Keras • PyTorch The first we thought…
  9. Python - the star in ML • SKlearn • Tensorflow

    • Keras • PyTorch The first we thought… How about JavaScript?
  10. – Jeff Atwood, co-founder of StackOverFlow Atwood’s Law Any application

    that can be written in JavaScript, will eventually be written in JavaScript.
  11. Computer Machine • CPU, Central Processing Unit • GPU, Graphics

    Processing Unit WebGL (Web Graphics Library)
  12. Basic Concepts (1/2) • Tensor
 Scalar, Vector, Matrix, Multi-dimensional Arrays

    • Epochs
 The number times that the learning algorithm will work through the entire training dataset 7 {11,30} A = [ a11 a12 a13 a21 a22 a23 ]
  13. Basic Concepts (1/2) • Tensor
 Scalar, Vector, Matrix, Multi-dimensional Arrays

    • Epochs
 The number times that the learning algorithm will work through the entire training dataset 7 {11,30} A = [ a11 a12 a13 a21 a22 a23 ] [ 48, 5, 246, 223, 115, 76, 127, 68, 162, 173, 198, 195, 134, 180, 68, 31, 123, 242, 195, 45, 240, 93, 99, 91, 204, 26, 188, 102, 121, 219, 156, 192, 254, 69, 230, 7, 224, 7, 171, 83, 170, 75, 224, 45, 178, 127, 49, 152, 218, 216, 118, 197, 177, 207, 67, 185, 186, 210, 160, 50, 71, 211, 215, 183, 183, 177, 152, 38, 4, 127, 137, 51, 106, 141, 15, 140, 115, 117, 13, 188, 24, 222, 245, 119, 137, 10, 238, 96, 54, 210, 249, 168, 16, 101, 253, 138, 111, 229, 147, 218, … ] Everything can be converted into Tensor
  14. Basic Concepts (2/2) • Loss Function
 Measure how well our

    linear equation fits the data • Optimizer Function
 Implement an algorithm that will adjust our coefficient values based on the output of the loss function • Train Function
 Iteratively run our optimizer function
  15. MSE

  16. In practice, we can do… Prediction Classification Recommendation Email filtering

    Image recognition Computer vision Language recognition … Personalization, Customer experience, Artificial intelligence, …