peace195/sppnet

Problem about maxpooling kernel size and strides

Closed this issue · 3 comments

The implementation of kernel size and strides of maxpooling in your code is this:

 for i in range(len(out_pool_size)):
        h_strd = previous_conv_size[0] / out_pool_size[i]
        w_strd = previous_conv_size[1] / out_pool_size[i]
        h_wid = previous_conv_size[0] - h_strd * out_pool_size[i] + 1
        w_wid = previous_conv_size[1] - w_strd * out_pool_size[i] + 1
        max_pool = tf.nn.max_pool(previous_conv,
                                   ksize=[1,h_wid,w_wid, 1],
                                   strides=[1,h_strd, w_strd,1],
                                   padding='VALID')
        if (i == 0):
            spp = tf.reshape(max_pool, [num_sample, -1])
        else:
            spp = tf.concat(axis=1, values=[spp, tf.reshape(max_pool, [num_sample, -1])])

But the official caffe code is this:
image

Can you give a reason about your implementation?
Thanks!

@yueruchen I developed the tensorflow version of SPP followed by the idea in the paper.

Thank you for your comparison. Let me clear something here:

  • I use floor() instead of ceil() function for stride window size.

  • I do not use padding in the SPP layer.

I have updated my code. Could you check it? Thank you very much.

   h_strd = math.ceil(previous_conv_size[0] / out_pool_size[i])
   w_strd = math.ceil(previous_conv_size[1] / out_pool_size[i])
    
   max_pool = tf.nn.max_pool(previous_conv,
                               ksize=[1,h_strd, w_strd, 1],
                               strides=[1,h_strd, w_strd,1],
                               padding='SAME')

I've run your code, but the accuracy of training and testing is very low.