Convolution(conv) layer Idea of a feature identifier We would like to extract a curve(feature from the image 0000 000 00030000 000 0 isualization of a curve detector filter ch9. CNN. V9b3 11
Convolution (conv) layer Idea of a feature identifier • We would like to extract a curve (feature) from the image ch9. CNN. V9b3 11
Discrete convo|utⅰon: Correlatⅰ on is more intuitive so we use correlation of the flipped version of h to implement convolution [1 h finish 253 convolution C(Om,n)=∑∑(m-J,n-k)×(,k) k: Flipped h ∑∑h(-m+一n+k)x/(,k) =-0k= correlation ch9. CNN. V9b3
Discrete convolution: Correlation is more intuitive • so we use correlation of the flipped version of h to implement convolution[1] ch9. CNN. V9b3 12 correlation convolution Flipped h j j k k flip j j k k h m j n k I j k C m n h m j n k I j k ( , ) ( , ) ( , ) ( , ) ( , ) ( ) 1 4 1 1 1 , ,find * 2 5 3 1 1 I h I h
Matlab(octave) code for convolution |=[141; 253] h=[11; 1-1] conv (,h) pause displit is the same as the following) conv(h, I pause disp('lt is the same as the following) xcorr2(, fliplr fliud(h)) ch9. CNN. V9b3 13
Matlab (octave) code for convolution • I=[1 4 1; • 2 5 3] • h=[1 1 ; • 1 -1] • conv2(I,h) • pause • disp('It is the same as the following'); • conv2(h,I) • pause • disp('It is the same as the following'); • xcorr2(I,fliplr(flipud(h))) ch9. CNN. V9b3 13
Correlation is more intuitive so we use correlation to implement convolution k k=1 k0- j=01 0 Flip h k j=0 Discrete convolution I*h, flip h, shift h and correlate with I [1] ch9. CNN. V9b3 14
Correlation is more intuitive, so we use correlation to implement convolution. • ch9. CNN. V9b3 14 j k j k k j Flip h Discrete convolution I*h, flip h ,shift h and correlate with I [1] j=0 1 2 j=0 1 k=1 k=0 j=0 1
Discrete convolution /*h, flip h, shift h and correlate with /[1 k =0 C(m, n) Flip h: is like this after the flip and no shift(m=0, n=0) The trick: I(j=o, k=0) needs to multiply to huili!(l-m+0, -n+O since m=1, n=0, so we shift the h(flip) pattern 1-bit to the right so Shift flipped h to m=l, n=0 we just multiply overlapped elements of I and hElp). Similarly k we do the same for all m,n values ch9. CNN. V9b3 15
Discrete convolution I*h, flip h ,shift h and correlate with I [1] • ch9. CNN. V9b3 15 j k j k k j Flip h: is like this after the flip and no shift (m=0,n=0) j k Shift Flipped h to m=1,n=0 m n j=0 1 C(m,n) The trick: I(j=0,k=0) needs to multiply to h(flip)(-m+0,-n+0), since m=1, n=0, so we shift the h(flip) pattern 1-bit to the right so we just multiply overlapped elements of I and h(flip). Similarly, we do the same for all m,n values