Convolution operation in CNN

In single image situation, the convolution is trivial, just apply multiple 2D convolution operations continuously, at last, summary the result. 

But if we have multiple images input, and need apply convolution on these input images, things become a bit complex. Suppose each image has the size W*H with depth of D.

The filter(kernel) size is K*K. And also we deploy M filters, so below code is to finish the 4D convolution:

for w in 1..W
  for h in 1..H
    for x in 1..K
      for y in 1..K
        for m in 1..M
          for d in 1..D
            output(w, h, m) += input(w+x, h+y, d) * filter(m, x, y, d)
          end
        end
      end
    end
  end
end

Reference: https://github.com/Yangqing/caffe/wiki/Convolution-in-Caffe:-a-memo


你可能感兴趣的:(Convolution operation in CNN)