It depends on your CNN architecture. Convolution operations, pooling, and non-linearities will work for any input dimensions. But when you use CNN for the image classification task it involves a fully-connected layer like MLP which does require the fixed-size inputs. Generally, object segmentation CNN (this type of model is called fully-convolutional) doesn’t involve any fully-connected layer so that’s why your training script is running successfully.