machine learning primer - department of computer science ...€¦ · machine learning primer polina...

81
Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321, ICML reinforcement learning tutorial 1

Upload: others

Post on 26-May-2020

24 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Machine Learning Primer

Polina Binder

Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321, ICML reinforcement learning tutorial

1

Page 2: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

2

Page 3: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

3

Page 4: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

What is machine learning?

● A class of algorithms that allows us to infer rules and parameters based on example data.

● In contrast to: hand coded rules

4

Page 5: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Types of Machine Learning

5

Page 6: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Supervised Learning

● Input: Training data and labels.● Goal: Learn function to map new

unlabelled data to labels

6

Page 7: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Supervised Learning: Classification vs. Regression

Input: data and discrete labelsGoal: Map data to discrete categories

Input: data and continuous valuesGoal: Learn an approximate function that maps data to values

7

Page 8: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Supervised Learning: Classification vs. Regression

Classification: labels are discrete values

Regression: labels are continuous values

8

Page 9: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Unsupervised Learning

● Input: training data without labels.● Goal: Learn structure in the data

9

Page 10: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Semi-Supervised Learning

● Input: training data, some of which is labelled● Goal: Learn function to map new unlabelled data to labels and/ or learn structure in

the data 10

Page 11: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Reinforcement Learning

● Framework for decision making○ Agent with the capacity to act○ Each action influences the

agent’s future state○ Success is measured by a

reward signal ○ Goal: Select actions to

maximize future reward

11

Page 12: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

12

Page 13: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

13

Page 14: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

14

Page 15: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

15

Page 16: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

16

Page 17: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

17

Page 18: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

18

Page 19: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

19

Page 20: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

20

Page 21: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

21

Page 22: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

22

Page 23: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

23

Page 24: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

24

Page 25: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Neurons - Building block of neural networks

25

Page 26: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Activation Functions

Bounded outputs Zero-centered Unbounded outputsTrains Faster 26

Page 27: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Combining neurons into layers

27

Page 28: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

28

Page 29: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

29

Page 30: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

30

Page 31: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Fully Connected Neural Network

● No connections within a layer● Each neuron is connected to

all neurons in the previous layer

● Used in classification problems, sometimes image recognition, etc.

Multilayer perceptron

31

Page 32: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Size of Fully Connected Neural Networks

32

Page 33: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Alternative: Convolutional Neural Networks● Not all layers are fully connected● Primarily used for image clustering, recognition, and classification● Convolutional layers - apply same filter at every location in the image● Pooling layers - reduce the size of the network and build in invariance to small

transformations

33

Page 34: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Convolution● Motivation: Learn a set of features that occur at all image locations● Apply same weights to every region of the image● Functions as a feature detector

● Example: 28x28 image, 5x5 filter - 25 shared weights

34

Page 35: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Pooling● Summarize the output of a group of units● Reduce the size of the representation ● Invariances to small perturbations in input.● Example: maximum of every 2x2 region

35

Page 36: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Convolutional neural networksPutting pooling and convolutional layers together

36

Page 37: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Higher layers capture more abstract information

37

Page 38: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

38

Page 39: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Recurrent Neural Networks

● Often used for language modelling● Hard to train long term dependencies, e.g. remembering

what happened hundreds of words ago. 39

Page 40: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Long Short-Term Memory (LSTM)

● Capable of learning long-term dependencies

● Composed of memory cells which have controllers saying when to store or forget information.

● Used for time series data

● Example application: text generation

40

Page 41: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

LSTM Components● x - input to LSTM● h - hidden state (output

vector)● c - cell state vector: (carries

information down the sequence of the LSTM)

● F - forget gate activation● I - input gate activation● O - output gate activation

41

Page 42: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

LSTM general behaviour● I = 0, F = 1: Remember

previous value● I = 1, F = 1: Add to previous

value● I = 0, F = 0; Erase the value● I = 1, F = 0: Overwrite the

value

42

Page 43: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Forget Gatesf_t between 0 (forget previous input) and 1 (keep) previous inputFunction of previous and current input

43

Page 44: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Ignore gate and temporarily cell statei - ignore or keep new inputs C - proposed new cell state

44

Page 45: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outputting DataCell state: output a combination of previous and new cell state.

45

Page 46: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

LSTMso - Output gate’s activation vector. Decides what the next hidden/output state should be.

h - Output vector of the LSTM

46

Page 47: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Application: Visual Odometry● Combines Convolutional and Recurrent layers

47

Page 48: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Restricted Boltzmann Machine● Bipartite Graph over hidden and visible nodes● Model the joint distribution of the data and the hidden layers.● Unsupervised and semi-supervised learning● Generative graphical model

48

Page 49: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Deep Belief NetworksSimilar to RBMs with multiple hidden layers.

49

Page 50: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

50

Page 51: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

51

Page 52: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

52

Page 53: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Loss Function● Example Loss Function:

● Predicted labels are a function of the weights and biases in the neural network.

● Loss Function is a function of weights and biases in the neural network. ● Weights and biases can be optimized by gradient descent.

53

Page 54: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Gradient Descent: Example● Loss function: C = f(w), w is a

weight● Weight’s gradient: dC/dw● dC/dw > 0: Decreasing w

increases C● dC/dw < 0: Increasing w

increases C● For small s > 0, updating

w’ = w - s * dC/dw decreases C● Repeatedly adjust weights

looking for local minimum in C

54

Page 55: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Back propagation - forward pass

Similar as before a tiny bit more math.

55

Page 56: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

56

Page 57: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Backpropagation and gradients

● Gradients at layer n-1 are functions of gradients in layer n.

● Gradients are multiplied as they’re passed through the network

● Leads to vanishing gradients: Gradients in lower levels are close to 0.

● Exploding gradients: Update too strongly, or have numerical overflow

57

Page 58: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Activation Functions

58

Page 59: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

59

Page 60: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

60

Page 61: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

61

Page 62: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Adversarial examples

Noise is set to be a function of the gradient in the neural network

62

Page 63: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Adversarial Stickers

Evtimov et al.Misclassified as speed signs

63

Page 64: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

64

Page 65: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

65

Page 66: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

66

Page 67: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

67

Page 68: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Outline● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

68

Page 69: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

69

Page 70: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

70

Page 71: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

71

Page 72: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

72

Page 73: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

73

Page 74: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

74

Page 75: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

75

reward at time t: rt

Page 76: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

76

Page 77: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

77

Page 78: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

78

Page 79: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

What is Deep Reinforcement Learning?

● Deep reinforcement learning is standard reinforcement learning where a deep neural network is used to approximate either a policy or a value function

● Deep neural networks require lots of real/simulated interaction with the environment to learn

● Lots of trials/interactions are possible in simulated environments, as done in ADS

79

Page 80: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

80

Page 81: Machine Learning Primer - Department of Computer Science ...€¦ · Machine Learning Primer Polina Binder Slides credit: MIT Deep Learning for Self Driving Cars, Toronto CSC 321,

Summary● Introduction to machine learning● How machine learning is used in self-driving cars● Deep learning

○ Neural Network Basics○ Structures in Neural Networks○ Training Neural Networks○ Challenges with deep learning

● Reinforcement learning

81