Why does LSTM sequence to label give undefined categories?

8 views (last 30 days)
When using an LSTM for sequence to label classification, training with 'trainNetwork' proceeds fine. However, when I try to classify with 'classify', the output is 'Undefined Category'. Why does this happen?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Jan 2019
This is likely due to having NaN values in the data.
As for why training proceeded fine, but classifying gave bad output, this is due to how the output of the neural net is treated internally. During training, the output from the network is a concrete number or vector, which may even be NaN.
Since it is something numeric, though, the training can proceed.
However, when calling classify, the classify function will try to get the output of the net, and then map it to a distinct category. Since the output from the net may be NaN based on training, or may give other not well formed outputs due to the NaN values in the data, this mapping will fail, resulting in the undefined categories.
To resolve this issue, do some pre-processing to remove the NaN values. You can completely remove the observations with NaN from your training and test data, or you can replace the NaN values with an arbitrary but consistent value.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!