- First column: a cell array where each cell contains a 1×m numeric row vector (the features)
- Second column: a categorical array representing the labels
Error received when applying example code for trainNetwork with numerical features to 2 d feature data, with integer classification codes
1 回表示 (過去 30 日間)
古いコメントを表示
I receieved the following error when running the example code for trainNetwork with numerical features on 2d numerical feature data with integer classification codes.
Error using trainNetwork
Invalid training data table for classification. Predictors must be in the first column of the table, as a cell array of image paths orimages. Responses must be after the first column, as categorical labels.
Error in DLNetwork2 (line 143)
[net,info] = trainNetwork(tblTrain,layers,options);
Error in TestReluCVM (line 213)
[net,info,Ypred,Ytest] = DLNetwork2(X',Y);
NOTE: The data was not image data. X was (n,2) numeric data; Y was (n,1) integer classification codes.
I don't understand how to fix the error.
Thank you.
Linda Ness
0 件のコメント
回答 (1 件)
TARUN
2025 年 6 月 12 日
The error you're encountering arises because trainNetwork expects the input table for classification with numeric features to follow a specific structure:
To fix your issue, you can convert the numeric feature matrix X into a cell array using num2cell(X,2) and convert the label vector Y into a categorical array. Then construct the table like this:
predictorCell = num2cell(X, 2);
Ycategorical = categorical(Y);
tbl = table(predictorCell, Ycategorical, 'VariableNames', {'Predictors','Response'});
Make sure to use this tbl for both training and testing data splits, and remove any one-hot encoding or splitvars logic that’s not needed here.
You can refer to the official MATLAB documentation to learn more about
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!