Why randomly apply torchvision.transforms.functional.resize won't cause an error?

Hi, I was rencently training a instance segmentation CNN and randomly apply “torchvision.transforms.functional.resize()” in the “getitem” method of the “Dataset” object(for data augmentation). However, I remembered that for a batch of data, the height and width of each images in the same batch should be the same, otherwise it will raise an error.
But my traning scripts runs succesfully? why?
many thanks!

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.