필터 지우기
필터 지우기

Why LSTM training is not done properly?

조회 수: 7 (최근 30일)
Nazila Pourhajy
Nazila Pourhajy 2021년 9월 5일
댓글: Nazila Pourhajy 2021년 9월 6일
Hi everyone!
I'm trying to train LSTM with 17521 data points. But with this amount of data, network training is not done properly. When I reduce the data to 8785(data for one year), the training is done to the end. But by increasing the data to 17521(data for two years), I receive NaN value in the YPred variable. This is my code:
YTrain = cell2mat(A_orig(2:17521,end))';
XTrain = cell2mat(A_orig(2:17521,3:end-1))';
XTrain = num2cell(XTrain,1);
YTrain = num2cell(YTrain,1);
%%Define Network Architecture
numResponses = size(YTrain{1},1);
featureDimension = size(XTrain{1},1);
numHiddenUnits = 500;
layers = [ ...
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(500) %%50
dropoutLayer(0.1) %%0.5
fullyConnectedLayer(numResponses)
regressionLayer];
maxepochs = 500;
options = trainingOptions('adam', ... %%adam
'MaxEpochs',maxepochs, ...
'GradientThreshold',1, ...
'InitialLearnRate',0.005, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',125, ...
'LearnRateDropFactor',0.2, ...
'Verbose',0, ...
'Plots','training-progress');
%%Train the Network
net = trainNetwork(XTrain,YTrain,layers,options);
%%Test the Network
YTest = cell2mat(A_orig(17546:26305,end))';
XTest = cell2mat(A_orig(17546:26305,3:end-1))';
XTest = num2cell(XTest,1);
YTest = num2cell(YTest,1);
net = resetState(net);
YPred = predict(net,XTest);
figure;
subplot(2,1,1);
y1 = (cell2mat(YPred(1:end, 1:end))); %have to transpose as plot plots columns
plot(y1);
title('Forcasted');
subplot(2,1,2);
y2 = (cell2mat(YTest(1:end, 1:end))');
plot(y2);
title('Observed');
When Number of data is 8785, the output for training is:
Please help me.Thanks alot.

답변 (1개)

the cyclist
the cyclist 2021년 9월 5일
I doubt that it is actually the size of the data that is the problem.
You could test that idea by running the second year (which is about the same size dataset as the one that runs) by itself. Perhaps the problem is something in the 2nd-year data, and not the size.
It's difficult to diagnose the problem without seeing the data. Can you upload the data in a MAT file?
  댓글 수: 7
the cyclist
the cyclist 2021년 9월 6일
Sorry, I have no experience in this.
Nazila Pourhajy
Nazila Pourhajy 2021년 9월 6일
Ok. Thank you for your time.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by