필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
Rafid Mustafiz
Rafid Mustafiz 2020년 5월 8일
댓글: Bjorn Gustavsson 2020년 5월 8일
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
Rafid Mustafiz
Rafid Mustafiz 2020년 5월 8일
Please write the corrected code as still I find error
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