Exercise:Convolution and Pooling

From Ufldl

Jump to: navigation, search
(Step 3a: Convolution)
(Step 3a: Convolution)
Line 98: Line 98:
'''Implementation tip:''' Using <tt>conv2</tt> and <tt>convn</tt>
'''Implementation tip:''' Using <tt>conv2</tt> and <tt>convn</tt>
-
Because the mathematical definition of convolution involves "flipping" the matrix to convolve with, to use MATLAB's convolution functions, you must first "flip" the weight matrix so that when MATLAB "flips" it according to the mathematical definition the entries will be at the correct place. For example, suppose you wanted to convolve two matrices <math>image</math> (a large image) and <math>W</math> (the feature) using <tt>conv2(image, W)</tt>, and W is a 3x3 matrix as below:
+
Because the mathematical definition of convolution involves "flipping" the matrix to convolve with (reversing its rows and its columns), to use MATLAB's convolution functions, you must first "flip" the weight matrix so that when MATLAB "flips" it according to the mathematical definition the entries will be at the correct place. For example, suppose you wanted to convolve two matrices <math>image</math> (a large image) and <math>W</math> (the feature) using <tt>conv2(image, W)</tt>, and W is a 3x3 matrix as below:
<math>
<math>

Revision as of 07:31, 20 May 2011

Personal tools