According to this paper, the output shape is N + H - 1, N is input height or width, H is kernel height or width. This is obvious inver
The formula for the output size from the tutorial assumes that the padding P is the same before and after the image (left & right or top & bottom).
Then, the number of places in which you put the kernel is:
W (size of the image) - F (size of the kernel) + P (additional padding before) + P (additional padding after).
But tensorflow also handles the situation where you need to pad more pixels to one of the sides than to the other, so that the kernels would fit correctly. You can read more about the strategies to choose the padding ("SAME" and "VALID") in the docs. The test you're talking about uses method "VALID".