LSTM model predicts wrong values?

조회 수: 2 (최근 30일)
玲
2024년 9월 29일
댓글: 2024년 10월 14일
Hello, Im trying machine learning with LSTM and unsupervised learning.
Here is trained LSTM network, and I checked this model works.
numHiddenUnits = 100;
Layers = [ ...
sequenceInputLayer(1, Normalization="zscore")
lstmLayer(numHiddenUnits,'OutputMode','sequence')
swishLayer
fullyConnectedLayer(1)
myRegressionLayer('mae')
];
options = trainingOptions('adam', ...
'MaxEpochs',40,...
'MiniBatchSize',32,...
'GradientThreshold',1,...
'InitialLearnRate',1e-2, ...
'Verbose',false, ...
'Plots', 'none');
%XTrain is (n*t sequence data)
%YTrain is (n*t sequence data)
[net, ~] = trainNetwork(XTrain, YTrain, Layers, options);
However, if the model predicts values with inputs in other environment,
%XTrain2 is (n*t sequence data in different environment from XTrain and YTrain environment for unsupervised learning)
dist = predict(net, XTrain2);
only head of sequence of output is lower than others as shown below.
Here is input data, and it doesn’t seem that there are differents of value between head of sequence and other parts.
In comparison with true data, this head of sequence of output is wrong value, and other sequence parts are comparatively correct values.
I’m sorry for my poor English. Can anyone help me what to do? Thank you.

채택된 답변

Aniket
Aniket 2024년 10월 10일
Hi ,
The issue you are encountering is a common LSTM issue which can arise due to multiple factors. LSTMs can take some time to learn the context of a sequence. Since the ‘XTrain2’ is from a different environment, the model was not quite accurate while predicting the first value.
The following strategies can help resolve the issue:
1. Data Normalisation: The code provided uses zscore function for normalisation. Make sure that the data in XTrain2 is normalized in the same way as XTrainbeacuse differences in data scaling can lead to poor predictions, especially at the start of a sequence.
If XTrain and XTrain2 have different distributions, the statistics (mean and standard deviation) from XTrainshould be used to normalize XTrain2.
You can also make use of Layer Normalisation and Batch Normalisation in MATLAB. Refer to the following documentation links for more details on these layers:
2. Model Regularization: Adding dropout layers or L2 regularization helps the model generalize better and reduce overfitting to the training data environment.
Refer to the following documentation links for more details on these layers:
I hope this helps resolve the issue.
  댓글 수: 1
玲
2024년 10월 14일
I think maybe normalisation causes this trouble.
I'll try, Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by