Error in image size U-Net
2 views (last 30 days)
Show older comments
I am trying to train a Unet for semantic segmentation.
My images sizes are X*Y*Z*5.
The X,Y, and Z are different between different images but the training is done using patches.
When the patch size is set to [64 64 32 5], the training runs successfully.
If I choose a patch size of higher X and Y dimensions such as [256 448 8 5], I got the error below:
Error using trainNetwork (line 165)
Unexpected image size: All images must have the same size.
Any thoughts ?
0 Comments
Answers (1)
Sourav Bairagya
on 18 Sep 2019
In U-Net, generally the patch sizes are determined in accordance with the subsequent max-pool layers, so that the down-sampling by factor of 2 at each max-pool layer goes smoothly and training goes well. Hence, to make the training smoother, it is important to determine a proper patch size and use the same for all input training samples irrespective of their original dimensions.
From the problem you are facing, it seems that your U-net architecture is defined to take the input patches of size (64X64X32). Hence, when you are trying feed patches of different size than this, it is throwing error.
If the network architecture is a pre-defined one, then you should use the defined input patch size for training.
If the network is defined by you, then you should change the input dimension in ‘imageInputLayer’ of ‘layers’ object to your desired one and then feed to ‘trainNetwork’ function.
Hope this will help you.
See Also
Categories
Find more on Image Filtering and Enhancement in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!