Why do I get the error "The output layer expects responses with the same sequence length and feature dimension 2" when using a data store in my network training?
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 20 Jul 2021
Answered: MathWorks Support Team
on 20 Jul 2021
I train a neuronal network using a combined data store.
I created two separate fileDatastore objects, one for the samples and one for the labels.
Then, I used the ReadFcn to prepare the samples and to prepare the labels.
Then, I defined the RNN layers and training options and attempt to train the network.
This results in the following error:
Error using trainNetwork (line 183)
Unexpected response size: The output layer expects responses with the same sequence length and feature dimension 2.
When separately defining XTrain and YTrain from the same Datastores, I do not get this error, but this requires the training data to be in memory which I want to avoid.
Accepted Answer
MathWorks Support Team
on 20 Jul 2021
When you create a categorical array from the numeric label, this array will think there is only one class because it hasn't been seen or been told otherwise. However, this categorical array needs to be aware it is storing elements that can belong to one of two classes.
The following documentation page will contain the necessary information about creating categorical arrays: https://www.mathworks.com/help/matlab/ref/categorical.html#d123e142165
Doing this should enable the network to train.
0 Comments
More Answers (0)
See Also
Categories
Find more on Define Shallow Neural Network Architectures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!