Slide 1

Slide 1 text

Machine Learning for Gophers @francesc

Slide 2

Slide 2 text

1996 - Exciting times

Slide 3

Slide 3 text

1996 - Exciting times (at least for computers)

Slide 4

Slide 4 text

2016 - Very exciting times

Slide 5

Slide 5 text

2016 - Very exciting times

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

deepmind.com/blog/alphago-zero-learning-scratch

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

What is Machine Learning?

Slide 12

Slide 12 text

What is Machine Learning? ● task: recognizing handwritten digits ● performance measure: percentage of digits labeled correctly ● experience: try to predict, fail, improve it, repeat

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

● Very simple technique y = X * W + b Logistic regression input biases weights prediction

Slide 15

Slide 15 text

● Average of how “off” predictions were J = -1/m * sum(dist(pred, label)) Cost function

Slide 16

Slide 16 text

● 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

Slide 17

Slide 17 text

mnist tutorial?

Slide 18

Slide 18 text

Can we do this in Go?

Slide 19

Slide 19 text

● Reading images ● Multiplying matrices ● Visualization of datasets ● Making it fast What do we need?

Slide 20

Slide 20 text

● matrices and linear algebra ● statistics ● probability distributions ● differentiation, integration, and optimization ● plotting ● and much more! gonum

Slide 21

Slide 21 text

1 2m (X * theta - y)2 Σ

Slide 22

Slide 22 text

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) }

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Let’s reinvent the wheel! github.com/campoy/mat ● focus on API over performance ● immutable matrices ● only float64 matrices

Slide 25

Slide 25 text

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()) }

Slide 26

Slide 26 text

demo time! * * not guaranteed to work

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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