Troubles in prediction using LSTM
Show older comments
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
on 20 Jan 2021
i have the same probleme please any one can help me
Answers (1)
Hong Gi Yeom
on 20 Mar 2019
0 votes
3 Comments
Salma Matoussi
on 2 Jul 2020
Hi, could you please explain how to normalize inputs and outputs with matlab for LSTM ? Thanks in advance
Hong Gi Yeom
on 2 Jul 2020
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;
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!