Troubles in prediction using LSTM

2 views (last 30 days)
Hong Gi Yeom
Hong Gi Yeom on 4 Feb 2019
Commented: nahed zemouri on 20 Jan 2021
I want to make a sequence-to-sequence regression using LSTM.
The training progress showed the convergence of RMSE and Loss to nearly zero.
However, the prediction is very bad, although I use the training data for test.
Whould you recommand what can I do to modify my program?
I do not know what the problem is. (I tried to change 'numHiddenUnits' and number of 'lstmLayer')
I hope your help.
My program is as follow;
%-------------------------------------------------------------------
% The size of Xtrain is 5x1 cell, and the size of each cell is 300x25000.
% The size of Ytrain is 5x1 cell, and the size of each cell is 3x25000.
numResponses = size(Ytrain{1},1); % 3
featureDimension = size(Xtrain{1},1); % 300
numHiddenUnits = 500;
layers = [ ...
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
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);
%-----------Training and Test--------------------
net = trainNetwork(Xtrain,Ytrain,layers,options);
h = predict(net,Xtrain,'MiniBatchSize',1);
  1 Comment
nahed zemouri
nahed zemouri on 20 Jan 2021
i have the same probleme please any one can help me

Sign in to comment.

Answers (1)

Hong Gi Yeom
Hong Gi Yeom on 20 Mar 2019
I found a problem with my code.
I write the answer for someone who will have the same problem.
To train the neural network, you have to normalize both input and output data.
I did not normalize the output data.
I hope this message can help someone.
  3 Comments
Hong Gi Yeom
Hong Gi Yeom on 2 Jul 2020
If you want to normalize the 'sig' data, you can used following code. The 'n_sig' is the normalized data m_sig = mean(sig); v_sig = std(sig); n_sig = (sig-m_sig)/v_sig;
nahed zemouri
nahed zemouri on 20 Jan 2021
if you want normalise your data you can use this function
function dataout = scaledata(datain,minval,maxval)
%
% Program to scale the values of a matrix from a user specified minimum to a user specified maximum
%
% Usage:
% outputData = scaleData(inputData,minVal,maxVal);
%
% Example:
% a = [1 2 3 4 5];
% a_out = scaledata(a,0,1);
%
% Output obtained:
% 0 0.1111 0.2222 0.3333 0.4444
% 0.5556 0.6667 0.7778 0.8889 1.0000
dataout = datain - min(datain(:));
dataout = (dataout/range(dataout(:)))*(maxval-minval);
dataout = dataout + minval;

Sign in to comment.

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!