Convolution operation in CNN

来源:互联网 发布:知乎 成人内容 老司机 编辑:程序博客网 时间:2024/06/08 03:11

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  endend

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


0 0
原创粉丝点击