在应用三维数据集进行​LSTM训练时,报错​:无效的训练数据。预​测变量和响应必须有相​同的观测值数目。

95 visualizzazioni (ultimi 30 giorni)
Jinjian
Jinjian il 29 Gen 2024
Commentato: ma il 9 Ott 2024
我应用滑动窗口技术,将原本时间序列的二维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 Commenti
Manikanta Aditya
Manikanta Aditya il 1 Mar 2024
ma
ma il 9 Ott 2024
你好,我也遇到了这样的问题,请问你最后解决了吗

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Big Data Processing in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!