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.
댓글 수: 0
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Learner App에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!