在应用三维数据集进行LSTM训练时,报错:无效的训练数据。预测变量和响应必须有相同的观测值数目。
97 次查看(过去 30 天)
显示 更早的评论
我应用滑动窗口技术,将原本时间序列的二维XTrain与YTrain变为三维cell数组,其中XTrain的cell数组与其中单元结构如图:其中numsamples为观察值的数量,windowsize为窗口大小,numfeatures为特征种类数量。193是序列数量。在这之中,XTrain与YTrain中的对应序列的numsamples-windowsize已经检查过,是相等的,其数值对应于时间步数量。
YTrain的cell数组与其中单元结构如图,其中各项英文的含义与上图相同
将上述XTrain与YTrain输入如下lstm网络中。
layers = [
sequenceInputLayer([windowsize 2])
flattenLayer
bilstmLayer(256,'InputWeightsInitializer','glorot','StateActivationFunction','softsign')
dropoutLayer(0)
bilstmLayer(128,'InputWeightsInitializer','glorot','StateActivationFunction','softsign')
dropoutLayer(0)
bilstmLayer(64,'InputWeightsInitializer','glorot','StateActivationFunction','softsign')
dropoutLayer(0)
fullyConnectedLayer(9)
regressionLayer];
%set train options
options = trainingOptions("adam", ...
MaxEpochs=1000, ...
InitialLearnRate=0.003,...
LearnRateSchedule="piecewise", ...
LearnRateDropFactor=0.5, ...
LearnRateDropPeriod=400, ...
GradientThreshold=1,...
SequencePaddingDirection="right", ...
Shuffle="every-epoch", ...
Plots="training-progress", ...
MiniBatchSize=128, ...
ExecutionEnvironment="multi-gpu",...
Verbose=0);
%train
net = trainNetwork(XTrain1,TTrain1,layers,options);
但是在训练时,出现报错,内容为:无效的训练数据。预测变量和响应必须有相同的观测值数目。
请问这是什么原因造成的呢?如果任何人能够提供任何帮助,将不胜感激!!
3 个评论
Manikanta Aditya
2024-3-1
CNN-LSTM in MATLAB - MATLAB Answers - MATLAB Central (mathworks.com) -> Similar issue in another MATLAB Answer
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Big Data Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!