Azzera filtri
Azzera filtri

Why this error? 'Transpose on ND array is not defined. Use PERMUTE instead.'

6 visualizzazioni (ultimi 30 giorni)
when I write the following code:
newImage = 'C:\Users\AKM Rahmatullah Clg\Documents\MATLAB\Pet Detection\Endoscopy Data\0028.png';
I=imread(newImage);
if ismatrix(I)
I = cat(3,I,I,I);
end
Iout = imresize(I, [227 227]);
imageFeatures = activations(convnet, Iout, featureLayer,'ExecutionEnvironment','cpu');
label = predict(classifier, imageFeatures)
Error is as below:
  2 Commenti
Rik
Rik il 8 Mag 2020
I'm guessing here: you're image is still RGB while your classifier expects a greyscale image.
Rafid Mustafiz
Rafid Mustafiz il 8 Mag 2020
I have trained this model using RGB so the classifier also formed using RGB image dataset,

Accedi per commentare.

Risposte (1)

Bjorn Gustavsson
Bjorn Gustavsson il 8 Mag 2020
Because transpose is only defined for 2-D arrays. For a 3-D (or larger dimensions) it is not unambiguous which dimensions you want matlab to transpose (1-2, 2-3, or 1-3). If you use permute, you have to explicitly instruct which dimensions to swap. If the size in your 3-D structure are the same in the dimensions you want to transpose you can also loop and transpose slice-by-slice. Compare
permute([1 2;3 4],[2,1]) - [1 2;3 4]'
For transposing dimension 1 and 2:
Itrp = permute(I,[2 1 3]);
But your problem might be that the function you call with I doesn't expect 3-D input data.
HTH
  2 Commenti
Bjorn Gustavsson
Bjorn Gustavsson il 8 Mag 2020
Unfortunately I cannot help with that, since I have never used these classification(deep learning? CNN?) functions. The error-message informs you that the error occurs on line 13 in some method-function for classreg, where an attempt to transpose the variable X fails. That function definitely expects the data to be 2-dimensional at most.
To understand what happens you should try to set the debug status to:
dbstop if error
that will make matlab stop execution at the point of the error, there you can inspect the variables in the workspace of the function (as well as move up the call-stack.) You should also rerun the training with the debugger step by step to see what happens with your training-data. Good luck.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by