leovandriel / caffe2_cpp_tutorial

C++ transcripts of the Caffe2 Python tutorials and other C++ example code
BSD 2-Clause "Simplified" License
431 stars 94 forks source link

Conv operator #55

Open edubois opened 6 years ago

edubois commented 6 years ago

I have two questions: When I read this: // >>> conv1 = brew.conv(model, data, 'conv1', dim_in=1, dim_out=20, kernel=5) model.AddConvOps("data", "conv1", 1, 20, 1, 0, 5, test);

What is dim_out? How do I compute it?

Is this operation a 1d convolution? Is there a 2D convolution example?

ShunChengWu commented 6 years ago

I believe that this is a 2D Conv. The kernel number define both kernel_h, kernel_w at the same time. The convolutional operation in default has dimensions of {batch, channel, height, weight}. The "dim_out=20" means that the output channel will be 20. Overall, this conv1 will take input with {batch, 1, height, weigth} using kernel size 5*5 and generate output with dimension of {batch, 20, height-4, weight-4}

You can also refer to this tutorial: https://github.com/leonardvandriel/caffe2_cpp_tutorial/blob/master/src/caffe2/binaries/mnist.cc#L47