Exercise:Convolution and Pooling

From Ufldl

Jump to: navigation, search
(Step 3a: Convolution)
(Step 3a: Convolution)
Line 81: Line 81:
     convolvedTemp = zeros(imageDim - patchDim + 1, imageDim - patchDim + 1, 3);
     convolvedTemp = zeros(imageDim - patchDim + 1, imageDim - patchDim + 1, 3);
     for channel = 1:3
     for channel = 1:3
-
       % Flip the feature matrix because of the definition of convolution, as explained
+
       % Flip the feature matrix because of the definition of convolution, as explained later
-
      % later
+
       Wt(:, :, channel) = flipud(fliplr(squeeze(Wt(:, :, channel))));
       Wt(:, :, channel) = flipud(fliplr(squeeze(Wt(:, :, channel))));
       convolvedTemp(:, :, channel) = conv2(squeeze(images(:, :, channel, imageNum)), squeeze(Wt(:, :, channel)), 'valid');
       convolvedTemp(:, :, channel) = conv2(squeeze(images(:, :, channel, imageNum)), squeeze(Wt(:, :, channel)), 'valid');
Line 92: Line 91:
end
end
</syntaxhighlight>
</syntaxhighlight>
 +
 +
The following implementation tip explains the "flipping" of feature matrices when using MATLAB's convolution functions:
   
   
<div style="border:1px solid black; padding: 5px">
<div style="border:1px solid black; padding: 5px">

Revision as of 07:29, 20 May 2011

Personal tools