Error using trainNetwork (line 154) Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All sequences must have the same feature dimension and at least one time step.
이전 댓글 표시
i'm working on a multiclass classification using matlab LSTM neural network on a dataset with 72 attributes and 56 classes but am having problem with the input argument to train the network.
i've split the data into training and testing and also converted the training set to cell array and pass it as Xtrain in the training network.
filename = "C:\Users\user\Documents\MATLAB\Examples\textanalytics\ClassifyTextDataUsingDeepLearningExample\MobileKSD2016.csv";
data = readtable(filename);
head(data)
data.class = categorical(data.class);
AB = data.class
f = figure;
f.Position(3) = 1.5*f.Position(3);
h = histogram(data.class);
xlabel("Class")
ylabel("Frequency")
title("Class Distribution")
cvp = cvpartition(data.class,'Holdout',0.1);
dataTrain = data(training(cvp),:);
dataTest = data(test(cvp),:);
textDataTrain = dataTrain.Pressure;
textDataTest = dataTest.Pressure;
YTrain = dataTrain.class;
YTest = dataTest.class;
T = table(textDataTrain)
inputSize = 71;
outputSize = 180;
numClasses = numel(categories(YTrain));
layers = [ ...
sequenceInputLayer(inputSize)
lstmLayer(outputSize,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
options = trainingOptions('adam', ...
'GradientThreshold',1, ...
'InitialLearnRate',0.01, ...
'Plots','training-progress', ...
'Verbose',0);
XTrain = table2cell(dataTrain)
YTrain = categorical(YTrain)
net = trainNetwork(XTrain,YTrain,layers,options);
YPred = classify(net,YTest);
accuracy = sum(YPred == YTest)/numel(YPred)
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Built-In Layers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!