Could anyone help me how to solve the error stating Y must be a vector of categorical responses or a cell array of categorical response sequences.

79 ビュー (過去 30 日間)
jaah navi
jaah navi 2021 年 6 月 20 日
コメント済み: Walter Roberson 2021 年 6 月 20 日
In my code Y is {3x1} cell
where Y{1,1}=12x1 double
Y{2,1}=12x2 double
Y{3,1}=12x3 double
Could anyone help me how should I change Y to a cell array of categorical response sequences.

回答 (2 件)


jaah navi
jaah navi 2021 年 6 月 20 日
With the help of your command I can execute Y(in my code Y is YTrain) but when i tried to implement in my neural network code, error exists as "Error using nnet.internal.cnn.util.NetworkDataValidator/assertValidSequenceResponse (line 349)
Invalid training data. Responses must be a vector of categorical responses, or a cell array of categorical response
sequences" for the following lines.
YTrain = cellfun(@categorical, YTrain, 'uniform', 0)
net = trainNetwork(XTrain,YTrain,layers,options);
Could you please help me to solve it.
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 6 月 20 日
Sorry, No, that is not valid training information.
If XTrain is a numeric array, then YTrain must be a categorical vector with number of entries equal to the number of samples in XTrain.
If XTrain is a cell array of numeric arrays, then YTrain must be a cell array, and each entry must be a categorical vector with number of entries each to the number of samples in the corresponding XTrain cell.
YTrain corresponds to class labels: each training sample (no matter how many features it has) corresponds to exactly one class.
Your Y{2,1} is 12 x 2. That would imply that you have two classes for each of 12 samples, or else that you have 12 classes for each of two samples. Either way is not permitted.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by