multi class classification using lstm model

10 次查看(过去 30 天)
I have a traing dataset having following dimentions
X_train has 70000*5 dimention in double format
Y_train has 70000*4 dimention in double format
but Y_train has only 0 and 1 like below format
0 1 0 0
0 1 1 1
and so on
when i convert the Y_train to make it a categorical one (and also after doing the transpose) it is coming with a dimention of 4*70000 categorical.
i have taken the NumClasses = 2 ( as only two classes are present 0 and 1)
but the error is showing as below
"Invalid training data. For classification tasks, responses must be a vector of
categorical responses. For regression tasks, responses must be a vector, a matrix,
or a 4-D array of numeric responses which must not contain NaNs."
can anyone help me, where I am doing wrong? basicaaly I am asking is if I have response data in 0 and 1 only but having 4 column like 0 1 0 1, 0 1 1 0, ... then how to do multi class clasification in Matlab?
Thank You in advance.

回答(1 个)

Sanjana
Sanjana 2023-3-3
Hi,
Based on the information provided, it appears that you are working with sequence or time-series data and are training an LSTM neural network. However, I noticed that the dimensions of ‘X_train’ are '70000x5' and ‘Y_train’ are '70000x4' in double format.I understand that you tried changing ‘Y_train’ to a categorical vector, but categorical is a data type for storing data with values from a finite set of discrete categories. It doesn't modify the shape of the data, it just provides efficient storage and convenient manipulation of data. You can refer to the documentation to create "categorical arrays", for further clarification.To work with sequential or time-series data, as per the documentation of "trainNetwork" function the input datatype for the function needs to be either a Numeric array or a data set of sequences specified as a cell array of numeric arrays. Therefore, you need to convert your data in such a way that ‘X_train’ would be a cell array of shape '70000x1' where each unit is a numerical array of type double.Similarly, you need to modify your ‘Y_train’ shape to '70000x1' so that it contains the information regarding the category of the corresponding time-series data in ‘X_train’, which can be either 0 or 1.For further help regarding arranging your data, you can refer to the following example, which demonstrates how to convert time-series data into a format suitable for training an LSTM neural network.
I hope this clarifies the steps you need to take to prepare your data for training the LSTM neural network.
  1 个评论
PRASANTA KUMAR MOHANTY
Thanks for your valuable replay.
But can you kindly tell how to modify my Y_train shape to 70000x1 ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Classification Learner App 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by