Last dimension disappears when I use an arrayDatastore

6 vues (au cours des 30 derniers jours)
Julien
Julien le 26 Fév 2025
Réponse apportée : Aneela le 12 Mar 2025
Hello everyone,
I was using a 4-d array of shape 8x234x1x1000 to train a ResNet, 8x234 being the size of my matrix, 1 being the number of channels and 1000 the number of points in my training set.
It worked well, however, I now want to use a multiple input neural network and hence need to use an arrayDatastore (I think?)
I specify : XTrain_features = arrayDatastore(features_mat(:,:,:,trainInd), "IterationDimension",4);
However, read(XTrain_features) gives :
1×1 cell array
{8×234 double}
And my neural network which input layer is imageInputLayer([8 234 1]) now gives an error saying I have no channel dimension.
Could someone please give me a workaround?
Thanks!

Réponse acceptée

Aneela
Aneela le 12 Mar 2025
MATLAB implicitly performs squeezing action on the arrays. It removes singleton dimensions from an array. So, if an array has a size of 2x3x1, MATLAB will often display or treat it as a 2x3 array. This is called “Trailing Singleton Dimensions”.
Please refer to the below MATLAB Answers from the community for more information on “Trailing Singleton Dimensions”:
Furthermore, for dlnetworks like “resnet18”, “resnet101”, “resnet50”, it is recommended to use “trainnet” for training.
Please refer to the following MathWorks documentation for more details on various datastores supported by “trainnet” for different input data.

Plus de réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by