0

I'm trying to use a max pool layer with filter size 2x2, so I expect the output size to be roughly half the input size. The input size is 9x14x64, but for some reason the output size is 7x12x64 (see the attached TensorBoard graph).

Here is the TensorFlow code:

layer = conv2d(layer, 64, 3, 2, activation_fn=None, scope="conv_2", name=name)
layer = max_pool2d(layer, 2, 1, scope="max_1", name=name)
layer = conv2d(layer, 32, 3, 1, activation_fn=None, scope="conv_3", name=name)

Am I missing something?

1 Answers1

0

It seems you are tensorflow default data_format NHWC; but your input format is NCHW. So you need to change your input format to NHWC

N -batch_size, H-height, W-width, C-num_channels 

Note: Max-pool only changes height and width of the input feature maps. There will be no effect on num_channels (it will be same for both input and output).

If you want to change the number of channels then you can use a 1x1 convolution layer as follows.

# 9 x 14 x 64
layer = max_pool2d(layer, 2, 2, scope="max_1", name=name, padding='SAME')
# output size 5x7x64
# to reduce num_channels use 1x1 conv
layer = conv2d(layer, 32, 1, 1, activation_fn=None, scope="conv_pool", name=name, padding='SAME')
# output size 5x7x32
Ishant Mrinal
  • 4,898
  • 3
  • 29
  • 47