回帰用のLSTMネッ​トワークで、sequ​ence-to-on​eの回帰学習を行う際​に、エラーになってし​まいます。

1 view (last 30 days)
Yoshito Saito
Yoshito Saito on 9 Aug 2019
Answered: Kenta on 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 Comments
Yoshito Saito
Yoshito Saito on 10 Aug 2019
回答、ありがとうございます。
YTrainをdouble型にして再度試しましたが、
「応答はn x 1のcell配列でなければなりません。」と怒られました。
もう少し、調べてみようと思います。
ありがとうございます。
Yoshito Saito
Yoshito Saito on 13 Aug 2019
ありがとうございます。
YTrainのデータ形式を通常のcell配列にしたところ、うまく走りました。
ご回答、誠にありがとうございました。

Sign in to comment.

Accepted Answer

Kenta
Kenta on 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)と定義しています。実際は、それぞれの手元のデータの値が入ります。

More Answers (0)

Categories

Find more on 時系列、シーケンス、およびテキストを使用した深層学習 in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!