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

Machine Learning for Gophers

Machine Learning for Gophers

My dotGo 2017 talk

Francesc Campoy Flores

November 06, 2017
Tweet

More Decks by Francesc Campoy Flores

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. What is Machine Learning? • task: recognizing handwritten digits •

    performance measure: percentage of digits labeled correctly • experience: try to predict, fail, improve it, repeat
  6. 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
  7. • Very simple technique y = X * W +

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

    * sum(dist(pred, label)) Cost function
  9. • 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
  10. • matrices and linear algebra • statistics • probability distributions

    • differentiation, integration, and optimization • plotting • and much more! gonum
  11. 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) }
  12. Let’s reinvent the wheel! github.com/campoy/mat • focus on API over

    performance • immutable matrices • only float64 matrices
  13. 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()) }