Troubles in prediction using LSTM

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 commentaire

nahed zemouri
nahed zemouri le 20 Jan 2021
i have the same probleme please any one can help me

Connectez-vous pour commenter.

Réponses (1)

Hong Gi Yeom
Hong Gi Yeom le 20 Mar 2019

0 votes

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 commentaires

Salma Matoussi
Salma Matoussi le 2 Juil 2020
Hi, could you please explain how to normalize inputs and outputs with matlab for LSTM ? Thanks in advance
Hong Gi Yeom
Hong Gi Yeom le 2 Juil 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 le 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;

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by