MATLAB Answers

Transposing matrices of a Dataset

조회 수: 3(최근 30일)
Gianmarco Plutino
Gianmarco Plutino 2 Jul 2020
Hello! I'm new of the comunity.
I imported a dataset containing the mat files where each of them represents a 3D matrix (43x512x210).
i need to transpose each of these matrices into matrices 210x512x43. The name I associated with the dataset is "imds" and the code to import it is:
digitDatasetPath = fullfile('C:\Users\User\Desktop\DB_BCI\DB');
imds = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'FileExtension', '.mat','LabelSource','foldernames');
the files mat in the dataset are 120:
would anyone be able to help me? Thank you!

  댓글 수: 0

Sign in to comment.

답변(1개)

Bjorn Gustavsson
Bjorn Gustavsson 2 Jul 2020
Take a look at the help and documentation of the matlab-function permute.
HTH

  댓글 수: 5

표시 이전 댓글 수: 2
Gianmarco Plutino
Gianmarco Plutino 2 Jul 2020
Thanks man i'll try this solution!
Gianmarco Plutino
Gianmarco Plutino 2 Jul 2020
Hello my friend,
i tried this solution:
for i=1:120
imds.Files{i,1}=permute(imds.Files{i,1},[3 2 1]);
end
and the command is executed without errors, but when i try to train the net it gives me the following error:
>> net = trainNetwork(imdsTrain,layers,options);
Error using trainNetwork (line 154)
The training images are of size 43x512x210 but the input layer expects images of size 210x512x43.
Caused by:
Error using nnet.internal.cnn.util.NetworkDataValidator/assertCorrectDataSizeForInputLayer (line 262)
The training images are of size 43x512x210 but the input layer expects images of size 210x512x43.
which makes me understand that the transformation of the matrices has not been successful.
Bjorn Gustavsson
Bjorn Gustavsson 2 Jul 2020
Check with:
size(imds.Files{i,1})
before and after the permutation.

Sign in to comment.


Translated by