フィルターのクリア

sequence to sequence classification - invalid training data

24 ビュー (過去 30 日間)
Floriana Vasile
Floriana Vasile 2021 年 11 月 5 日
コメント済み: Floriana Vasile 2021 年 11 月 16 日
Hi, I'm training a classification network:
%% def
inputSize = 1;
numHiddenUnits = 200;
numClasses = 2;
layers = [ ...
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,'OutputMode','last')
dropoutLayer(0.5,"Name","dropout") %
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
I generated my data, which are:
  • the labels, that are arrays long 4000 elements (which are categorical), memorized in a cell array like this:
  • the signals, each long 4000 samples, memorized in a cell array, like this:
I tried to ''stick'' to this example (https://it.mathworks.com/help/deeplearning/ug/sequence-to-sequence-classification-using-deep-learning.html) to understand how to prepare the cell array for the labels, but when I use trainNetwork it gives me this error:
Error using trainNetwork (line 184)
Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.
I can't understand what's wrong, I tried to prepare the data in a different way, but it didn't work anyway, can you suggest what to try?

採用された回答

Srivardhan Gadila
Srivardhan Gadila 2021 年 11 月 16 日
The issue here is that you are using the bilstmLayer with 'OutputMode' set to 'last', which means that it would only output the last time step of the sequence and hence your network output would not be a 1x4000 categorical but instead 1x1 categorical.
Hence set the 'OutputMode' to 'sequence' and execute the code, it should work fine.
Refer to the documentation of bilstmLayer & description of OutputMode property for more information.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by