Week1: Dimensions formula for padding = 0, stride = 2

Perhaps I have missed something in the lecture, but I encounter problems with the formula

w’ = int((w - f + 2*padding) / stride)+1

given in the lecture, in the case when the padding is 0 and the stride is greater than 1:

Let w = 4, padding = 0 and stride = 2, using a filter size of f=3

The formula gives w’ = int((4-3+2*0)/2)+1 = int(1/2)+1 = 0+1 = 1,

which is not correct in my opinion, since the answer should be w’=2.

Can someone please tell me where I go wrong? Thank you very much in advance!

The point is that if w_{in} = 4, f = 3 and s = 2 with no padding, then the first stride is off the end, right? So you can only do one application of the filter and you get w_{out} = 1. You can only apply the filter in positions where the complete filter fits within the input space. Draw the picture and it will make sense.

With everything the same but s = 1 in that case, then w_{out} would be 2.

Or if you have everything the same but w_{in} = 5, then w_{out} would also be 2. But that’s not what you have.

Thank you very much! I totally missed that.

1 Like