Theano conv2d and max_pool_2d
When implementing a Convolutional Neural Network (CNN) in theno, everyone encounters two operator variants conv2d
:
And the max-pooling implementation:
My questions:
- What is the difference between the two implementations
conv2d
? -
What is the difference between using the
subsample
for argumentconv2d
and themax_pool_2d
subsampling application afterconv2d
?
This is the difference between:conv2d( ..., subsample=(2,2) )
and
a = conv2d( ..., subsample = (1,1) ) max_pool_2d( a, ds = (2,2) )
source to share
In response to your first question, here is the section of Theano doc that refers to it :
There are two similar implementations for conv2d:
signal.conv2d and nnet.conv2d.
The former implements traditional 2D convolution, while the latter implements the convolutional layers present in convolutional neural networks (where 3D filters and pooling across multiple input channels).
Under the hood, they both call the same function, so the only difference is the user interface.
As for your second question, the result is different. Equivalent call:
conv2(..., subsample=(2,2))
:
conv2d(...,subsample=(1,1))[:,:,::2,::2]
In other words, it conv2d
does not accept a max over the entire join area, but rather an element in the index of [0,0]
the join area.
source to share