Le Lecture 9 9 - Convolu lutional l Neural l Networks I2DL: Prof. Niessner, Prof. Leal-Taixé 1
Fu Fully C Connected N Neural N Network Width Width Width Depth I2DL: Prof. Niessner, Prof. Leal-Taixé 2
Pr Problems usin ing FC FC Lay ayers on on Ima mages • How to process a tiny image with FC layers 5 weights 5 5 3 3 neuron layer I2DL: Prof. Niessner, Prof. Leal-Taixé 3
Pr Problems usin ing FC FC Lay ayers on on Image ages • How to process a tiny image with FC layers 25 weights For the whole 5×5 image on 1 5 channel 5 3 3 neuron layer I2DL: Prof. Niessner, Prof. Leal-Taixé 4
Problems usin Pr ing FC FC La Layers on Im Images • How to process a tiny image with FC layers 75 weights For the whole 5×5 image on the 3 5 channel 5 3 3 neuron layer I2DL: Prof. Niessner, Prof. Leal-Taixé 5
Pr Problems usin ing FC FC La Layers on Im Images • How to process a tiny image with FC layers 75 weights For the whole 5×5 image on the three 75 weights 5 channels pe per ne neuron on 75 weights 5 3 3 neuron layer I2DL: Prof. Niessner, Prof. Leal-Taixé 6
Pr Problems usin ing FC FC La Layers on Im Images al image with FC layers • How to process a no normal 1000 1000 3 3 neuron layer I2DL: Prof. Niessner, Prof. Leal-Taixé 7
Pr Problems usin ing FC FC La Layers on Im Images al image with FC layers • How to process a no normal PRACTICAL AL 3 𝑐𝑗𝑚𝑚𝑗𝑝𝑜 weights IMPRAC 1000 1000 3 1000 neuron layer I2DL: Prof. Niessner, Prof. Leal-Taixé 8
Wh Why n not s ot simply ly m mor ore F FC L Lay ayers? We cannot make networks arbitrarily complex • Why not just go deeper and get better? – No structure!! – It is just brute force! – Optimization becomes hard – Performance plateaus / drops! I2DL: Prof. Niessner, Prof. Leal-Taixé 9
Bet Better er Way Way than an FC C ? • We want to restrict the degrees of freedom – We want a layer with structure – Weight sharing à using the same weights for different parts of the image I2DL: Prof. Niessner, Prof. Leal-Taixé 10
Usin Using C CNNs in s in C Comp mputer V Visio ision [Li et al., CS231n Course Slides] Lecture 12: Detection and Segmentation I2DL: Prof. Niessner, Prof. Leal-Taixé 11
Convolu lutions I2DL: Prof. Niessner, Prof. Leal-Taixé 12
Wh What at ar are e Con onvol olution ons? " 𝑔 ∗ = ) 𝑔 𝜐 𝑢 − 𝜐 𝑒𝜐 !" 𝑔 = red = blue 𝑔 ∗ = green Convolution of two box functions Convolution of two Gaussians Application of a filter to a function — The ‘smaller’ one is typically called the filter kernel I2DL: Prof. Niessner, Prof. Leal-Taixé 13
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 ‘Slide’ fi filter r kern rnel from left to right; at each position, compute a single value in the output data I2DL: Prof. Niessner, Prof. Leal-Taixé 14
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 4 ⋅ 1 3 + 3 ⋅ 1 3 + 2 ⋅ 1 3 = 3 I2DL: Prof. Niessner, Prof. Leal-Taixé 15
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 3 ⋅ 1 3 + 2 ⋅ 1 3 + (−5) ⋅ 1 3 = 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 16
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 0 2 ⋅ 1 3 + (−5) ⋅ 1 3 + 3 ⋅ 1 3 = 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 17
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 0 1 −5 ⋅ 1 3 + 3 ⋅ 1 3 + 5 ⋅ 1 3 = 1 I2DL: Prof. Niessner, Prof. Leal-Taixé 18
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 0 1 10/3 3 ⋅ 1 3 + 5 ⋅ 1 3 + 2 ⋅ 1 3 = 10 3 I2DL: Prof. Niessner, Prof. Leal-Taixé 19
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 0 1 10/3 4 5 ⋅ 1 3 + 2 ⋅ 1 3 + 5 ⋅ 1 3 = 4 I2DL: Prof. Niessner, Prof. Leal-Taixé 20
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 0 1 10/3 4 4 2 ⋅ 1 3 + 5 ⋅ 1 3 + 5 ⋅ 1 3 = 4 I2DL: Prof. Niessner, Prof. Leal-Taixé 21
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 𝑔 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 𝑔 ∗ 3 0 0 1 10/3 4 4 16/3 5 ⋅ 1 3 + 5 ⋅ 1 3 + 6 ⋅ 1 3 = 16 3 I2DL: Prof. Niessner, Prof. Leal-Taixé 22
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 ?? 3 0 0 1 10/3 4 4 16/3 ?? What to do at boundaries? I2DL: Prof. Niessner, Prof. Leal-Taixé 23
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 4 3 2 -5 3 5 2 5 5 6 1/3 1/3 1/3 ?? 3 0 0 1 10/3 4 4 16/3 ?? What to do at boundaries? Option 1: Shrink 3 0 0 1 10/3 4 4 16/3 I2DL: Prof. Niessner, Prof. Leal-Taixé 24
Wh What at ar are e Con onvol olution ons? Discrete case: box filter 0 4 3 2 -5 3 5 2 5 5 6 0 1/3 1/3 1/3 ?? 3 0 0 1 10/3 4 4 16/3 ?? What to do at boundaries? 0 ⋅ 1 3 + 4 ⋅ 1 3 + 3 ⋅ 1 3 = 7 3 Option 2: Pa Pad (often 0’s) 7/3 3 0 0 1 10/3 4 4 16/3 11/3 I2DL: Prof. Niessner, Prof. Leal-Taixé 25
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 5 6 7 9 -1 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 3 + −1 ⋅ 3 + −1 ⋅ 2 + −1 ⋅ 0 + −1 ⋅ 4 = 15 − 9 = 6 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 26
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 5 6 7 9 -1 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 2 + −1 ⋅ 2 + −1 ⋅ 1 + −1 ⋅ 3 + −1 ⋅ 3 = 10 − 9 = 1 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 27
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 1 + −1 ⋅ −5 + −1 ⋅ −3 + −1 ⋅ 3 + −1 ⋅ 2 0 -1 0 = 5 + 3 = 8 I2DL: Prof. Niessner, Prof. Leal-Taixé 28
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 -7 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 0 + −1 ⋅ 3 + −1 ⋅ 0 + −1 ⋅ 1 + −1 ⋅ 3 = 0 − 7 = −7 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 29
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 -7 9 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 3 + −1 ⋅ 2 + −1 ⋅ 3 + −1 ⋅ 1 + −1 ⋅ 0 = 15 − 6 = 9 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 30
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 -7 9 2 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 3 + −1 ⋅ 1 + −1 ⋅ 5 + −1 ⋅ 4 + −1 ⋅ 3 = 15 − 13 = 2 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 31
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 -7 9 2 -5 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 0 + −1 ⋅ 0 + −1 ⋅ 1 + −1 ⋅ 6 + −1 ⋅ −2 0 -1 0 = −5 I2DL: Prof. Niessner, Prof. Leal-Taixé 32
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 -7 9 2 -5 -9 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 1 + −1 ⋅ 3 + −1 ⋅ 4 + −1 ⋅ 7 + −1 ⋅ 0 = 5 − 14 = −9 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 33
Convolutions on Im Images -5 3 2 -5 3 Image 5×5 4 3 2 1 -3 1 0 3 3 5 -2 0 1 4 4 Output 3×3 6 1 8 5 6 7 9 -1 -7 9 2 -5 -9 3 Kernel 3×3 0 -1 0 -1 5 -1 5 ⋅ 4 + −1 ⋅ 3 + −1 ⋅ 4 + −1 ⋅ 9 + −1 ⋅ 1 = 20 − 17 = 3 0 -1 0 I2DL: Prof. Niessner, Prof. Leal-Taixé 34
Im Image Filters • Each kernel gives us a different image filter Edge detection Box mean −1 −1 −1 1 1 1 Input 1 −1 8 −1 1 1 1 9 −1 −1 −1 1 1 1 Sharpen Gaussian blur 0 −1 0 1 2 1 1 −1 5 −1 2 4 2 16 0 −1 0 1 2 1 I2DL: Prof. Niessner, Prof. Leal-Taixé 35
Recommend
More recommend