imageImageLayer with variable image size for Fully Convolutional Network (FCN)

17 次查看(过去 30 天)
Hello all,
I am modifying a pretrained CNN to an FCN and I want to create an input layer that takes variable image dimensions.
layers(1) = imageInputLayer([imageSize 3], 'Name', layers(1).Name,...
'DataAugmentation', layers(1).DataAugmentation, ...
'Normalization', layers(1).Normalization);
Is it possible to initialize imageSize with undefined variables so that it will take automatically the size of each image given in the training process? I tried imageSize = [none none] and other definitions but it is not working.
Appreciate any kind of help!
Thank you

回答(1 个)

Rushil
Rushil 2025-5-7
Hello
With reference to convolutional filters, variable size filters are not typically supported as part of traditional convolutional models. This is because:
  • The network architecture (especially convolutional and fully connected layers) requires knowledge of the input size to initialize weights and set up internal structures.
  • If variable input sizes were permitted, the model would need to be dynamic, with all weights changing for every image size. However, traditional convolutional models are designed to operate with fixed input dimensions.
As a workaround, you can consider the usual practice of resizing the images to a common size before passing into the network.
To do this, you can use functions such as “augmentedImageDatastore” to resize images in batches. To learn more about this function, refer to the link below:
Hope this helps in getting started!

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by