cesarsalgado
cesarsalgado

Reputation: 1026

Can't understand shape(output) = (shape(value) - ksize + 1) / strides in TensorFlow docs

In the following excerpt from http://tensorflow.org/api_docs/python/nn.md#pooling

shape(output) = (shape(value) - ksize + 1) / strides

where the rounding direction depends on padding:

I can't understand the formula above. I am familiar with following formula though:

shape(out) = (shape(value) - ksize + 2*pad)/strides+1.

Are the two formulas equivalent?

For example, let's say shape(value) = 9, ksize = 3, strides = 2, and padding = 'SAME'.

In the first formula the shape(output) will be (9-3+1)/2 = 7/2 = 3.5 and rounding down results in 3.

In the second formula the shape(output) will be (9-3+2*1)/2 + 1 = 5

It doesn't seem to be the same formula. Even if I round up the first one, the result will be 4.

In addition to that, the padding definition seems to be inverted. Isn't the 'SAME' padding that includes partial windows?

Upvotes: 3

Views: 609

Answers (1)

cesarsalgado
cesarsalgado

Reputation: 1026

I think I figured out the problem. The two formulas become equivalent if you assume that the appropriate padding is already included in shape(value). But I still think the definition of the padding types have been swapped in the documentation. I created an issue to report that: https://github.com/tensorflow/tensorflow/issues/196

Upvotes: 2

Related Questions