Transposing matrices of a Dataset

2 次查看(过去 30 天)
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!

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2020-7-2
Take a look at the help and documentation of the matlab-function permute.
HTH
  5 个评论
Gianmarco Plutino
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 2020-7-2
Check with:
size(imds.Files{i,1})
before and after the permutation.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by