globalAver​agePooling​1dLayer error

조회 수: 4 (최근 30일)
Bram Stegeman
Bram Stegeman 2022년 1월 16일
편집: Bram Stegeman 2022년 1월 18일
Dear Community,
I want to train and test a 1D convolutional network for sequence - to - sequence classification.
I have the following architecture:
layers = [ ...
sequenceInputLayer(numFeatures)
convolution1dLayer(filterSize,numFilters1,Padding="same")
reluLayer
convolution1dLayer(filterSize,numFilters1,Padding="same")
reluLayer
globalAveragePooling1dLayer
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer( ...
'Classes',classes, ...
'ClassWeights',classWeights)];
If I include the globalAveragePooling1dLayer after my second relu layer than i get the following error:
" Error using trainNetwork (line 184) Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical" .
Without the globalAveragePooling1dLayer I don't get the error and trainings starts. What is the problem?

채택된 답변

Tomaso Cetto
Tomaso Cetto 2022년 1월 18일
편집: Tomaso Cetto 2022년 1월 18일
Hi Bram!
As you've noticed, the globalAveragePooling1dLayer plays a critical role here. This is because that layer removes the time dimension by pooling over it globally (i.e. keeping only the largest value in the sequence). This layer is useful for sequence-to-one tasks, where the output isn't a sequence. The output here would be a numClasses x numObservations array.
However, because yours is a sequence-to-sequence problem, you want the output to be a numClasses x numObservations x sequenceLength array (with the sequence dimension conserved). So in that case, the globalAveragePooling1dLayer isn't appropriate for your workflow, because of the fact it removes the sequence dimension.
Hope this helps, and let me know if you have any other questions!
Best,
Tomaso
  댓글 수: 1
Bram Stegeman
Bram Stegeman 2022년 1월 18일
Dear Tomaso,
Thanks for your clear explanation, this helps!
Best,
Bram

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

추가 답변 (1개)

yanqi liu
yanqi liu 2022년 1월 17일
yes,sir,may be check Ydata,such as use
Ydata2 = categorical(Ydata);
to get categorical vector,then train
  댓글 수: 1
Bram Stegeman
Bram Stegeman 2022년 1월 18일
편집: Bram Stegeman 2022년 1월 18일
Dear yanqi liu,
This was not the problem. See the anwser of Tomaso.
Best,
Bram

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

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by