1/85

Machine Learning

IS

* (because the tools will do most of the work)

Easy!

INSANELY

Easy!

INSANELY

Easy!

2/85

Doing Hard Stuff

Can be

Easy

* ...if you have the right tools and know how to use them

3/85

4/85

Machine Learning Is Hard!

It’s common knowledge.

* everybody.knows/already

5/85

Machine Learning

Machine Learning Is Easy!

Machine learning is a type of artificial intelligence (AI)

Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without being explicitly programmed.

whatis.techtarget.com/definition/machine-learning

Machine learning

6/85

Machine Learning Is Easy!

Where would you use that?

7/85

Machine Learning Is Easy!

  • Classification
  • Regression
  • Clustering
  • Density Estimation
  • Dimensionality Reduction

Machine learning tasks

8/85

Machine Learning Is Easy!

  • CLASSIFICATION:
    • inputs are divided into two or more classes
    • the learner must produce a model that assigns unseen inputs to one or more of these classes.

* typically supervised

Machine learning tasks

9/85

Machine Learning Is Easy!

  • REGRESSION: the outputs are continuous rather than discrete.

Machine learning tasks

* also typically supervised

10/85

Machine Learning Is Easy!

Machine learning tasks

  • CLUSTERING: a set of inputs is to be divided into groups.

* Unlike in classification, the groups are not known beforehand, making this typically an unsupervised task.

Machine learning tasks

11/85

Machine Learning Is Easy!

  • DENSITY ESTIMATION: finds the distribution of inputs in some space.

Machine learning tasks

12/85

Machine Learning Is Easy!

  • DIMENSIONALITY REDUCTION: simplifies inputs by mapping them into a lower-dimensional space.

https://en.wikipedia.org/wiki/Machine_learning

Machine learning tasks

13/85

Machine Learning Is Easy!

  • Decision tree learning

Approaches

14/85

Machine Learning Is Easy!

Approaches

15/85

Machine Learning Is Easy!

Approaches

16/85

Machine Learning Is Easy!

Approaches

17/85

Machine Learning Is Easy!

Approaches

18/85

Machine Learning Is Easy!

Approaches

19/85

Machine Learning Is Easy!

Approaches

20/85

Machine Learning Is Easy!

Approaches

21/85

Machine Learning Is Easy!

Approaches

22/85

Machine Learning Is Easy!

Approaches

23/85

Machine Learning Is Easy!

Approaches

24/85

Machine Learning Is Easy!

Approaches

25/85

Machine Learning Is Easy!

Approaches

26/85

Machine Learning Is Easy!

Approaches

27/85

Machine Learning Is Easy!

Approaches

28/85

Machine Learning Is Easy!

Approaches

29/85

Machine Learning Is Easy!

Approaches

30/85

Machine Learning Is Easy!

Approaches

31/85

Machine Learning Is Easy!

  • Learning classifier systems
  • Artificial neural networks

Approaches

32/85

Machine Learning Is Easy!

  • Artificial neural networks

Approaches

https://en.wikipedia.org/wiki/Machine_learning

33/85

Machine Learning Is Easy!

Bear with me just a few more minutes

34/85

Machine Learning Is Easy!

http://www.dictionary.com/browse/artificial-neural-network

A neural network is a processing device, either an algorithm or actual hardware, whose design was inspired by the design and functioning of animal brains

35/85

Machine Learning Is Easy!

http://www.dictionary.com/browse/artificial-neural-network

A network of many very simple processors ("units" or "neurons"), each possibly having a (small amount of) local memory.

36/85

Machine Learning Is Easy!

http://www.dictionary.com/browse/artificial-neural-network

The units are connected by unidirectional communication channels ("connections"), which carry numeric data.

37/85

Machine Learning Is Easy!

http://www.dictionary.com/browse/artificial-neural-network

The units operate only on their local data and on the inputs they receive via the connections.

38/85

Machine Learning Is Easy!

https://en.wikipedia.org/wiki/Artificial_neural_network

These systems are self-learning and trained, rather than explicitly programmed

39/85

Machine Learning Is Easy!

Three prominent learning paradigms:

40/85

Machine Learning Is Easy!

Reinforcement learning

  • No data is initially known; The network is trained with each data input, with the goal of determining a policy for selecting actions that minimizes some measure of a long-term cost

41/85

Machine Learning Is Easy!

Unsupervised learning

  • Given a data set, the network is trained until some cost function is minimized

42/85

Machine Learning Is Easy!

Supervised learning

  • given a set of example data, the aim is to find a function that closely approximates the known product or classification for each datum

43/85

Machine Learning Is Easy!

Enough with the theory. What now?

  • Build a basic 1-layer neural network
  • Learn how to train the network
  • Add more layers
  • Training tips and tricks: overfitting, dropout, learning rate decay...
  • Build convolutional networks

44/85

Machine Learning Is Easy!

Train a Neural Network

...to do what?

Data classification

...of hand-written characters

45/85

Machine Learning Is Easy!

Our task:

Train a network to recognize hand-written numeric digits

46/85

Machine Learning Is Easy!

Where to start?

We have 10,000 examples to train with

With the MNIST data set

http://yann.lecun.com/exdb/mnist/

47/85

Machine Learning Is Easy!

Designing a network

A neural network may have any number of layers

48/85

Machine Learning Is Easy!

Designing a network

We will start with a simple one-layer network

49/85

Machine Learning Is Easy!

Designing a network

Each "neuron" in a neural network does a weighted sum of all of its inputs, adds a constant called the "bias" and then feeds the result through some non-linear activation function.

50/85

Machine Learning Is Easy!

Designing a network

  • 1-layer network
  • 10 output neurons since we want to classify digits into 10 classes (0 to 9)

51/85

Machine Learning Is Easy!

How does the network process input?

  • Initialize a 10x784 matrix
  • Each column represents a neuron
  • Each row represents the weight assigned to a pixel for that neuron

52/85

Machine Learning Is Easy!

How does the network process input?

  • For each image:
    • For each column in weights matrix:
      • Compute the weighted sum of all the pixels in the image

53/85

Machine Learning Is Easy!

How does the network process input?

  • Given:
    • X is the matrix containing our 100 images
    • W is the matrix of neuron weights
  • Then :
    • L = X.W (matrix multiply).

54/85

Machine Learning Is Easy!

Almost there!

...but it has been proven to be useful to also introduce a “bias” offset

  • So we calculate L = X.W + b

http://stackoverflow.com/questions/2480650/role-of-bias-in-neural-networks?lq=1

55/85

Machine Learning Is Easy!

...and lastly...

It is also helpful to transform the output of the system to “accentuate” the classification

  • So we calculate

L = fa(X.W + b)

https://www.quora.com/What-is-the-role-of-the-activation-function-in-a-neural-network

56/85

Machine Learning Is Easy!

The activation function

For classification problems, the softmax function has been shown to be effective

(...and, lastly…)

57/85

Machine Learning Is Easy!

Told you it was easy.

Now you know neural networks. You’re welcome!

That’s it.

58/85

Machine Learning Is Easy!

Ok, let’s do it!

Um. Where do we start?

59/85

Machine Learning Is Easy!

...I don’t want to do a bunch of complicated matrix algebra...

It’s ok.

You don’t have to.

60/85

Machine Learning Is Easy!

Train a Neural Network

“That looks like a product logo.”

“He’s probably selling something.”

61/85

Machine Learning Is Easy!

What’s TensorFlow ?

TensorFlow is an open source software library for machine learning in various kinds of perceptual and language understanding tasks.

https://en.wikipedia.org/wiki/TensorFlow

62/85

Machine Learning Is Easy!

What’s TensorFlow ?

It is currently used for both research and production by [at least] 50 different teams in dozens of commercial products, such as speech recognition, Gmail, Google Photos, and search.

https://en.wikipedia.org/wiki/TensorFlow

63/85

Machine Learning Is Easy!

What’s TensorFlow ?

TensorFlow was originally developed by the Google Brain team for Google's research and production purposes and later released under the Apache 2.0 open source license on November 9, 2015.

https://en.wikipedia.org/wiki/TensorFlow

64/85

Machine Learning Is Easy!

...and what’s a “Tensor” again ?

A "tensor" is like a matrix but with an arbitrary number of dimensions. A 1-dimensional tensor is a vector. A 2-dimensional tensor is a matrix. And then you can have tensors with 3, 4, 5 or more dimensions.

65/85

Machine Learning Is Easy!

Wanna see TensorFlow at work?

Try the TensorFlow Playground

http://playground.tensorflow.org/

66/85

Machine Learning Is Easy!

So... TensorFlow is a web tool?

67/85

Machine Learning Is Easy!

TensorFlow : get started (Mac)

Python

Install the latest version of python 3 from https://www.python.org/downloads/

TensorFlow

pip3 install --upgrade tensorflow

MatPlotLib

pip3 install --upgrade matplotlib

68/85

Machine Learning Is Easy!

TensorFlow : get started (Windows)

Anaconda, Python

https://www.continuum.io/downloads#windows

Anaconda comes with matplotlib built in.

TensorFlow

(in the anaconda shell)

pip3 install --upgrade tensorflow

69/85

Machine Learning Is Easy!

Now get the example project

$ git clone …

https://github.com/martin-gorner …

/tensorflow-mnist-tutorial

70/85

Machine Learning Is Easy!

See this exercise online

71/85

Machine Learning Is Easy!

72/85

There are 50,000 training digits in this dataset.

We feed 100 digits into the training loop each iteration

Thus the system will have seen all the training digits once after 500 iterations. We call this an "epoch".

73/85

Machine Learning Is Easy!

Can we make it work better?

Add Layers

mnist_2.0_five_layers_sigmoid.py

74/85

Machine Learning Is Easy!

Now we’re getting somewhere. What next?

Learning rate decay

mnist_2.1_five_layers_relu_lrdecay.py

75/85

Machine Learning Is Easy!

What happens if we train the network “too well”?

Overfitting

Dropout!

Overfitting

mnist_2.2_five_layers_relu_lrdecay_dropout.py

76/85

Machine Learning Is Easy!

Is there a more optimal way to train for two-dimensional input?

77/85

Machine Learning Is Easy!

Core Building Block:

the convolutional layer

Convolutional Neural Networks

78/85

Machine Learning Is Easy!

small receptive field

Convolutional Neural Networks

79/85

Machine Learning Is Easy!

Forward pass:

dot product between the filter and the input

Convolutional Neural Networks

80/85

Machine Learning Is Easy!

Learns filters that activate when it detects some specific type of feature at some spatial position in the input.

Convolutional Neural Networks

81/85

Machine Learning Is Easy!

Applying CNN’s to the MNIST data:

98%

Convolutional Neural Networks

mnist_3.0_convolutional.py

82/85

Machine Learning Is Easy!

Wow -- 98% accuracy.

Can we do better?

More COWBELL!

DROPOUT

DROPOUT !

83/85

Machine Learning Is Easy!

Considerations?

84/85

Machine Learning Is Easy!

Applications?

85/85

Machine Learning Is Easy!

(Mic dropped)

That’s it. Thanks!

Special thanks to

Martin Görner

Twitter: @martin_gorner

Google +: plus.google.com/+MartinGorner