When applying a convolution with kernel height kh and width kw, total padding height ph and width pw, and strides sh and sw, the shape of the output generated from an input of height nh and width nw is:
⌊(nh−kh+ph+sh)/sh⌋×⌊(nw−kw+pw+sw)/sw⌋
This formula simplifies under certain conditions. If padding is set to ph=kh−1 and pw=kw−1, the output shape reduces to ⌊(nh+sh−1)/sh⌋×⌊(nw+sw−1)/sw⌋. Furthermore, if the input dimensions are exactly divisible by the strides, the output shape simplifies to (nh/sh)×(nw/sw).