Hi Alex,

Sorry for the late response, hope it will still be usefull.

Concerning your first question, after the last contraction block (conv 3), we have dimensions divided by 8 (that’s 2**3) and 128 features. after that we will apply the first expanding block. There is a difference between the picture and the code. The first convolution of the expansion block changes the dimension from 128 to 64, at it keeps 64 to the end of the block. The next expansion block starts with 128 dims because of the direct concatenation (skip connection), but ends with 32. I will adjust the code, so it reads:


conv2d(in, in, stride=1)

conv2d(in, in, stride=1)

convTransposed2d(in, out, stride=2)

For your second issue, you can use the AdaptativeMaxPooling2d, available in pytorch, where you specify the exact output that you want, so you can control the size reduction without bothering with odd or even sizes.

hope that helps, and let me know if you have managed to solved it,

Good coding,


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store