Shai
Shai

Reputation: 114786

Theano conv2d and max_pool_2d

When implementing a convolutional neural network (CNN) in theno one comes across two variants of conv2d operator:

And an implementation of max-pooling:

My questions are:

  1. What is the difference between the two implementations of conv2d?
  2. What is the difference between the use of subsample argument of conv2d and the application of max_pool_2d subsampling after conv2d?
    That is what is the difference between:

    conv2d( ..., subsample=(2,2) ) 
    

    and

    a = conv2d( ..., subsample = (1,1) )
    max_pool_2d( a, ds = (2,2) )
    

Upvotes: 3

Views: 5474

Answers (1)

nouiz
nouiz

Reputation: 5071

In answer to your first question, here is the section of the Theano docs that addresses it:

Two similar implementation exists for conv2d:

signal.conv2d and nnet.conv2d.

The former implements a traditional 2D convolution, while the latter implements the convolutional layers present in convolutional neural networks (where filters are 3D and pool over several input channels).

Under the hood they both call the same function, so the only difference is the user interface.

Regarding your second question, the result is different. The equivalent call to:

conv2(..., subsample=(2,2))

would be:

conv2d(...,subsample=(1,1))[:,:,::2,::2]

In other words conv2d doesn't take the max over the whole pooling region, but rather the element at index [0,0] of the pooling region.

Upvotes: 7

Related Questions