Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining a stride of (2, 2) in Keras -- what is the second value?

I'm a bit confused by the idea of a stride that is, say, (2, 2) in keras.

What is the second 2 in the tuple (2,2) doing?

I'd understand if the stride was (2), because then we'd be moving a filter across an image by 2 pixels.

If we are striding by 2 along x and 2 along y, then we'd be running diagonally across an image. That doesn't make much sense.

The Keras documentation is not clear.

Thanks.

like image 677
Monica Heddneck Avatar asked Mar 12 '17 06:03

Monica Heddneck


1 Answers

Indeed the two values are related to the two dimensions x and y along which we move the filters. You will move the filters along both dimensions, so you will need to know the strides that you want to use. The thing you are misinterpreting is that the filters won't move by increasing both x and y values at the same time. They will be incremented one by one, so first you will go along the x axis 2 by 2, without changing y, the you will go down y by one step of 2 and start over along x, and so on...

So it just gives you flexibility on the steps sizes you want to make vertically and horizontally. In cases where you are working with simple pictures it makes sense to use the sames steps (2,2) or (3,3) for example. But you never know what this tool can be used for so they made it general in case someone wants to subsample more on one axis or the other.

Does that answer your question?

like image 183
Nassim Ben Avatar answered Oct 20 '22 10:10

Nassim Ben