Why this error? 'Transpose on ND array is not defined. Use PERMUTE instead.'
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291371/image.png)
2 comentarios
Rik
el 8 de Mayo de 2020
I'm guessing here: you're image is still RGB while your classifier expects a greyscale image.
Respuestas (1)
Bjorn Gustavsson
el 8 de Mayo de 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 comentarios
Bjorn Gustavsson
el 8 de Mayo de 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.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!