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.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!