在应用三维数据集进行LSTM训练时,报错:无效的训练数据。预测变量和响应必须有相同的观测值数目。
Show older comments
我应用滑动窗口技术,将原本时间序列的二维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 Comments
Manikanta Aditya
on 1 Mar 2024
English Translation:
When applying a three-dimensional dataset for LSTM training, an error is reported: Invalid training data. The predictor and response must have the same number of observations. I applied the sliding window technique to convert the original time series’ two-dimensional XTrain and YTrain into a three-dimensional cell array. In this, the numsamples-windowsize of the corresponding sequence in XTrain and YTrain has been checked and is equal, and its value corresponds to the number of time steps. The above XTrain and YTrain are input into the following LSTM network.
However, during training, an error occurred, the content is: Invalid training data. The predictor and response must have the same number of observations.
What is the cause of this? If anyone can provide any help, I would be very grateful.
Manikanta Aditya
on 1 Mar 2024
CNN-LSTM in MATLAB - MATLAB Answers - MATLAB Central (mathworks.com) -> Similar issue in another MATLAB Answer
ma
on 9 Oct 2024
你好,我也遇到了这样的问题,请问你最后解决了吗
Answers (0)
Categories
Find more on Parallel and Cloud in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!