Lecture 11: Convolutional Neural Networks 2 CS109B Data Science 2 Pavlos Protopapas, Mark Glickman and Chris Tanner 1
Outline Review from last lecture 1. Training CNNs 2. BackProp of MaxPooling layer 3. Layers Receptive Field 4. Saliency maps 5. Transfer Learning 6. A bit of history 7. CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 2
Outline Review from last lecture 1. Training CNNs 2. BackProp of MaxPooling layer 3. Layers Receptive Field 4. Saliency maps 5. Transfer Learning 6. A bit of history 7. CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 3
From last lecture + ReLU + ReLU CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 4
Lab Lecture Quiz Homework CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 5
Lab Lab Lecture Lecture Quiz Quiz Homework Homework CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 6
Input Output 1 Filter (size=32X32, (size=32X32) (size=3x3X3, channels=3) stride = 1, padding = same) How many parameters does the layer have? n_filter x filter_volume + biases = total number of params 1 x (3 x 3 x 3) + 1 = 28 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER
Examples I have a convolutional layer with 16 3x3 filters that takes an RGB • image as input. How many parameters does the layer have? • 16 x 3 x 3 x 3 + 16 = 448 Biases (one Number of Number of Size of filters per filter) channels of Filters prev layer CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 8
Examples • Let C be a CNN with the following disposition: • Input: 32x32x3 images • Conv1: 8 3x3 filters, stride 1, padding=same Conv2: 16 5x5 filters, stride 2, padding=same • • Flatten layer • Dense1: 512 nodes • Dense2: 4 nodes • How many parameters does this network have? (8 x 3 x 3 x 3 + 8) + (16 x 5 x 5 x 8 + 16) + (16 x 16 x 16 x 512 + 512) + (512 x 4 + 4) Conv1 Conv2 Dense1 Dense2 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 9
Input Output Filter (size=32X32, (size=32X32, 8 x (size=3X3x3, channels=3) stride = 1, channels = 8) padding = same) filter x 1 How many parameters does the layer have if I want to use 8 filters? n_filters x filter_volume + biases = total number of params CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 8 x (3 x 3 x 3) + 8 = 224
Output Input Filter (size=32X32, (size=16X16, 16 x (size=5X5X8, channels=8) channels=16) stride = 2, padding = same) 16 filters How many parameters does the layer have if I want to use 16 filters? n_filters x filter_volume + biases = total number of params 16 x (5 x 5 x 8) + 16 = 3216 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER
Input Fully Connected Fully Connected Flatten (size=16X16, (size= 16X16X16) (n_nodes=512) (n_nodes=4) channels=16) How many parameters … ? input x FC1_nodes + FC2_nodes = total number of params (16x16x16) x 512 + 512 + 512 x 4 + 4 = 2,099,716 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER
Representation Learning Task: classify cars, people, animals and objects … CNN Layer 1 CNN Layer 2 CNN Layer n FCN CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 13
What do CNN layers learn? • Each CNN layer learns filters of increasing complexity. • The first layers learn basic feature detection filters: edges, corners, etc. • The middle layers learn filters that detect parts of objects. For faces, they might learn to respond to eyes, noses, etc. • The last layers have higher representations: they learn to recognize full objects, in different shapes and positions. CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 14
3D visualization of networks in action http://scs.ryerson.ca/~aharley/vis/conv/ https://www.youtube.com/watch?v=3JQ3hYko51Y CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 15
Outline Review from last lecture 1. Training CNNs 2. BackProp of MaxPooling layer 3. Layers Receptive Field 4. Saliency maps 5. Transfer Learning 6. A bit of history 7. CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 16
CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 17
Outline Review from last lecture 1. Training CNNs 2. BackProp of MaxPooling layer 3. Layers Receptive Field 4. Saliency maps 5. Transfer Learning 6. A bit of history 7. CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 18
Backward propagation of Maximum Pooling Layer Forward mode, 3x3 stride 1 Activation of layer L rest of the network rest of the network 2 4 8 3 6 9 3 4 2 5 5 4 6 3 1 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 19
Backward propagation of Maximum Pooling Layer Forward mode, 3x3 stride 1 Activation of layer L rest of the network rest of the network 2 4 8 3 6 9 9 3 4 2 5 5 4 6 3 1 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 20
Backward propagation of Maximum Pooling Layer Forward mode, 3x3 stride 1 Activation of layer L rest of the network rest of the network 2 4 8 3 6 9 8 9 3 4 2 5 5 4 6 3 1 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 21
Backward propagation of Maximum Pooling Layer Forward mode, 3x3 stride 1 Activation of layer L rest of the network rest of the network 2 4 8 3 6 9 8 8 9 3 4 2 5 5 4 6 3 1 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 22
Backward propagation of Maximum Pooling Layer Forward mode, 3x3 stride 1 Activation of layer L rest of the network rest of the network 2 4 8 3 6 9 8 8 9 3 4 2 5 9 6 6 5 4 6 3 1 7 7 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 23
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network rest of the network 2 4 8 3 6 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 24
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network rest of the network 2 4 8 3 6 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 25
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network rest of the network 2 4 8 3 6 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 26
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network rest of the network 2 4 8 3 6 +1 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 27
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network rest of the network 2 4 8 3 6 +1 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 28
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network +3 rest of the network 2 4 8 3 6 +1 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 29
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network +3 rest of the network 2 4 8 3 6 +1 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 30
Backward propagation of Maximum Pooling Layer Backward mode. Large fonts represents the values of the derivatives of the current layer (max-pool) and small font the corresponding value of the previous layer. Activation of layer L rest of the network +4 rest of the network 2 4 8 3 6 +1 1 9 3 8 1 8 9 3 4 2 5 1 9 4 6 2 6 5 4 6 3 1 6 7 2 7 1 7 2 3 1 3 4 2 7 4 5 7 CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 31
CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 32
Outline Review from last lecture 1. Training CNNs 2. BackProp of MaxPooling layer 3. Layers Receptive Field, dilated CNNs 4. Saliency maps 5. Transfer Learning 6. A bit of history 7. CS109B, P ROTOPAPAS , G LICKMAN A ND T ANNER 33
Recommend
More recommend