回帰用のLSTMネットワークで、sequence-to-oneの回帰学習を行う際に、エラーになってしまいます。
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Yoshito Saito
am 9 Aug. 2019
Beantwortet: Kenta
am 14 Aug. 2019
回帰用のLSTMネットワークで、sequence-to-oneの回帰学習を行いたく、下記のようなlayerを作りました。
layers = [ ...
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(50)
dropoutLayer(0.5)
fullyConnectedLayer(numResponses)
regressionLayer];
maxEpochs = 60;
miniBatchSize = 20;
options = trainingOptions('adam', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',0.01, ...
'GradientThreshold',1, ...
'Shuffle','never', ...
'Plots','training-progress',...
'Verbose',0);
学習の際は、このコードで実行しようとしたところ、エラーが出力されてしまいました。
エラー内容:「無効な学習データです。出力モードが'last'である再帰層では、応答は数値応答の行列でなければなりません。」
net = trainNetwork(XTrain,YTrain,layers,options);
XTrainは、277×1 のcell配列で、各cellには、8個の指標の時系列データが格納されています。(8×n のdouble型)
YTrainは、277×1 のcell配列で、各cellには、各XTrainに対応する数値が格納されています。(1×1のdouble型)
データ形式が間違っているのか、学習のコードが間違っているのか、ご存じの方がいらっしゃいましたら、ご教示いただけたら幸いです。
よろしくお願いいたします。
3 Kommentare
Akzeptierte Antwort
Kenta
am 14 Aug. 2019
XTrain=cell(227,1);
for i=1:227
XTrain{i}=ones(8,1);
end
YTrain=ones(227,1);
numResponses = size(YTrain{1},1);
featureDimension = size(XTrain{1},1);
numHiddenUnits = 200;
layers = [ ...
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(50)
dropoutLayer(0.5)
fullyConnectedLayer(numResponses)
regressionLayer];
maxEpochs = 60;
miniBatchSize = 20;
options = trainingOptions('adam', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',0.01, ...
'GradientThreshold',1, ...
'Shuffle','never', ...
'Plots','training-progress',...
'Verbose',0);
net = trainNetwork(XTrain,YTrain,layers,options);
教えていただいた形式をもとにのようにするとうまく実行できましたが、いかがでしょうか。
YTrainをones(227,1)と定義しています。実際は、それぞれの手元のデータの値が入ります。
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!