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

6 次查看(过去 30 天)
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 个评论
Rik
Rik 2020-5-8
I'm guessing here: you're image is still RGB while your classifier expects a greyscale image.
Rafid Mustafiz
Rafid Mustafiz 2020-5-8
I have trained this model using RGB so the classifier also formed using RGB image dataset,

请先登录,再进行评论。

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2020-5-8
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 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2020-5-8
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Deep Learning for Image Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by