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

Machine Learning for Gophers

Machine Learning for Gophers

My dotGo 2017 talk

D8e5d79ca42edc07693b9c1aacaa7e5e?s=128

Francesc Campoy Flores

November 06, 2017
Tweet

Transcript

  1. Machine Learning for Gophers @francesc

  2. 1996 - Exciting times

  3. 1996 - Exciting times (at least for computers)

  4. 2016 - Very exciting times

  5. 2016 - Very exciting times

  6. name elo rating matches Fan Hui 3,144 5:0 against Fan

    Hui Lee Sedol 3,739 4:1 against Lee Sedol Master 4,858 60:0 against professional players Zero 5,185 100:0 against AlphaGo Lee 89:11 against AlphaGo Master training hardware 176 GPU 48 TPU 4 TPU 4 TPU 2017 - E_TOO_EXCITE
  7. deepmind.com/blog/alphago-zero-learning-scratch

  8. What is Machine Learning? “A computer program is said to

    learn from experience E, with respect to some task T, and some performance measure P, if its performance on T as measured by P improves with experience E” - Tom Mitchell
  9. What is Machine Learning? “A computer program is said to

    learn from experience E, with respect to some task T, and some performance measure P, if its performance on T as measured by P improves with experience E” - Tom Mitchell
  10. What is Machine Learning? “A computer program is said to

    learn from experience E, with respect to some task T, and some performance measure P, if its performance on T as measured by P improves with experience E” - Tom Mitchell
  11. What is Machine Learning?

  12. What is Machine Learning? • task: recognizing handwritten digits •

    performance measure: percentage of digits labeled correctly • experience: try to predict, fail, improve it, repeat
  13. Input 0 0 0 0 0 0 0 0 0

    0 255 0 0 255 0 0 0 0 255 0 0 255 0 0 0 0 255 255 255 255 0 0 0 0 0 0 0 255 0 0 0 0 0 0 0 255 0 0 0 0 0 0 0 255 0 0 0 0 0 0 0 0 0 0 28 x 28 , 4
  14. • Very simple technique y = X * W +

    b Logistic regression input biases weights prediction
  15. • Average of how “off” predictions were J = -1/m

    * sum(dist(pred, label)) Cost function
  16. • Finding the W and b that minimize J •

    We know what direction to go by deriving J vs W and b not gonna show that Optimizing
  17. mnist tutorial?

  18. Can we do this in Go?

  19. • Reading images • Multiplying matrices • Visualization of datasets

    • Making it fast What do we need?
  20. • matrices and linear algebra • statistics • probability distributions

    • differentiation, integration, and optimization • plotting • and much more! gonum
  21. 1 2m (X * theta - y)2 Σ

  22. gonum func ComputeCost(X, y, theta *mat.Dense) float64 { m, _

    := X.Dims() h := new(mat.Dense) h.Mul(X, theta) h.Sub(h, y) h.MulElem(h, h) return mat.Sum(h) / float64(2*m) }
  23. None
  24. Let’s reinvent the wheel! github.com/campoy/mat • focus on API over

    performance • immutable matrices • only float64 matrices
  25. ComputeCost with github.com/campoy/mat func ComputeCost(X, y, theta mat.Matrix) float64 {

    h := mat.Minus(mat.Product(X, theta), y) return mat.Product(h, h).Sum() / float64(2 * X.Rows()) }
  26. demo time! * * not guaranteed to work

  27. References github.com/campoy/mat github.com/campoy/goml github.com/campoy/justforfunc github.com/campoy/tools/imgcat

  28. Merci! @francesc VP of Developer Relations at source{d} sourced.tech