fitclinear with tall array that contains images

조회 수: 2 (최근 30일)
H Yang
H Yang 2020년 10월 10일
댓글: H Yang 2020년 10월 18일
Not sure if anyone has ever tried this since I found 0 trace of this error message on Google.
I am using MATLAB 2018a, trying to train a binary SVM using fitclinear(). My data are RGB images, which I load into a imageDatastore. Then I wrote a custom ReadFn to downsample them and converted from uint8 to float using imresize and im2double, respectively.
Then I created a tall array from the imageDatastore (I also put the labels into a tall array with the same numebr of rows). I reshaped the images from 3-D array to 1-by-154587 vector, which I assume is needed for fitclinear(). So now I have a tall array of n-by-1, n being the number of training images, and each cell is a vector of datatype double. And I also have another tall array of n-by-1 containing the corresponding labels for each training example.
Then I simply called SVMmodel=fitclinear(tallarry1,talllabel);
But I got the following error:
Error using tall/fitclinear (line 305)
Argument 1 to FITCLINEAR must be one of the following data types: float.
Any thought will be appreciated.
HY

답변 (1개)

Divya Gaddipati
Divya Gaddipati 2020년 10월 18일
I understand that your input data is a tall array of cells of size n-by-1. Whereas, the input to fitclinear should be specified as an n-by-p full or sparse matrix.
Converting your input data tallarry1 and talllabel to a matrix format would resolve your issue.
  댓글 수: 1
H Yang
H Yang 2020년 10월 18일
I tried to do that with cell2mat, but it returns another error:
Error using tall/fitclinear (line 320)
Incompatible non-scalar tall array arguments. Each of the tall arrays must be the same size in the first
dimension, must be derived from a single tall array, and must not have been indexed differently in the
first dimension (indexing operations include functions such as VERTCAT, SPLITAPPLY, SORT, CELL2MAT,
SYNCHRONIZE, RETIME and so on).
Learn more about errors encountered during GATHER.
Is there a different cell2mat for tallarray?
thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by