why do I have error that "Unexpected response size: If the network outputs sequences, then the responses must be arrays with feature dimension 5."

2 次查看(过去 30 天)
Hi!
I am studying deeplearning toolbox.
To solve the problem of classifying 5 class, I created a sequence data store using a custom datastore.
The number of classes is 5 in total, and the last layer of the neural network is fullyConnectedLayer(5), which matches the number of classes.
However, when I try to train it, I get an error "Unexpected response size: If the network outputs sequences, then the responses must be arrays with feature dimension 5."
The last layer of the neural network is set to 5, so there is no problem I think.
What is the problem?
Thanks for reading.

回答(1 个)

Avadhoot
Avadhoot 2024-1-16
Hi Youngwoo,
I understand you're encountering an error related to the output dimensions of your network. Given that your input data is a sequence, the network is treating this as a sequence-to-sequence model, which requires the output to also be a sequence with a feature dimension of 5. Here, "feature dimension" means that each output should be an array with a length of 5.
The error arises because the "classificationLayer" at the end of your network is designed to predict one of the 5 classes, whereas your model expects a vector of length 5 for its output. If your goal is to perform classification on your data, the "numClasses" property is relevant. However, if you're solving a sequence prediction problem, you'll need to format your data so that the output is a sequence of vectors, each with a length of 5.
For more information about the following topics, refer to the below documentation:
  1. Classification Layer : https://www.mathworks.com/help/deeplearning/ug/create-simple-deep-learning-network-for-classification.html#:~:text=fully%20connected%20layer.-,Classification%20Layer,-The%20final%20layer
  2. Sequence-to-sequence classification: https://www.mathworks.com/help/deeplearning/ug/sequence-to-sequence-classification-using-deep-learning.html
I hope it helps.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by