sequence learning using LSTM
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Hello everyone, I am trying to use an LSTM to predict and forecast the position of a vehicle and I would like to know how to train the system.
I have a dataset consisting of 230 vehicle samples i.e. a cell of 1 x 230 where each sample is a matrix of 4 features and the respective sequence length(60 - 300 timesteps). The objective is to forecast future (1 - 5 timesteps) steps of a given vehicle sample.
I am refering to this example to understand the way to forecast and this to see how to train the model for prediction. But in both the examples the LSTM model is used as a many to one example.
my features are in the x,y coordinate..
I would like to know how to train a LSTM model on multiple sequences containing mutltiple features and learn the behaviour of the vehicle model!
Thanks in advance
採用された回答
Asvin Kumar
2019 年 12 月 30 日
編集済み: Asvin Kumar
2019 年 12 月 30 日
Have a look at the example here: https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.lstmlayer.html#d117e90134
Although this links to another example that uses the bilstmLayer, the underlying principles remain the same. You can use a fullyConnectedLayer with as many outputs as necessary for your use case. By setting the ‘OutputMode’ to ‘sequence’ in your lstmLayer and preparing the predictors as mentioned in the first example which you linked, you should be able to achieve your desired result.
In your case, the output size of the fullyConnectedLayer would be 4, I suppose. Your predictors would be shifted in time by 1-5 steps, whichever you're trying to forecast. It might make sense to drop the softmaxLayer and the classificationLayer from the example for your requirement.
11 件のコメント
Sharan Magavi
2020 年 1 月 8 日
Hello,
thanks for the response. I have used a similar architecture for my model but unfortunately my model predicts/forecasts the SAME values over multiple timesteps. The model fails to learn the underlying relations between the various features of the dataset. Any recommendations about the solution for this problem?
Asvin Kumar
2020 年 1 月 9 日
Can you please provide more details on your network architecture and how you're preparing your dataset?
Sharan Magavi
2020 年 1 月 13 日
Hello Asvin,
So my model is as exactly as in this example and I've not made any changes. Also, like in that example, i'm using only 1 sequence right now, not the entire dataset.
My dataset for this training example is a sequence of 4 x 150 ( 4 features, 150 timesteps). As shown in the example, i'm using 90% of the timesteps to train the model and remaining 10% as the test. So when I want to evaluate the system, i utilise the predictAndUpdateState method for the network.
Hope this clarifies the question. awaiting your reply
Asvin Kumar
2020 年 1 月 13 日
Hard to tell even with this information. Can you please share your code and sample data to test it on?
Sharan Magavi
2020 年 1 月 13 日
Unfortunately, I am not authorised to share the data.
Sharan Magavi
2020 年 1 月 13 日
code is as follows
n = randperm(size(trackdata,2), 1); %% select any random number
data = trackdata{1,n}; %extract track information to train
numTimeStepsTrain = floor(0.9*size(data, 2));
dataTrain = data(:,1:numTimeStepsTrain+1);
dataTest = data(:,numTimeStepsTrain+1:end);
mu = mean(dataTrain, 2);
sig = std(dataTrain, 0, 2);
dataTrainStandardized = (dataTrain - mu) ./ sig;
XTrain = dataTrainStandardized(:,1:end-1);
YTrain = dataTrainStandardized(:, 2:end);
numFeatures = size(XTrain, 1);
numResponses = size(YTrain, 1);
numHiddenUnits1 = 200;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits1,'OutputMode','sequence')
fullyConnectedLayer(numResponses)
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',250, ...
'GradientThreshold',1, ...
'InitialLearnRate',0.005, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',125, ...
'LearnRateDropFactor',0.2, ...
'Verbose',0, ...
'SequenceLength', 'shortest', ...
'Plots','training-progress');
% training
net = trainNetwork(XTrain,YTrain,layers,options);
%
dataTestStandardized = (dataTest - mu) ./ sig;
XTest = dataTestStandardized(:,1:end-1);
net = predictAndUpdateState(net,XTrain);
[net,YPred(:,1)] = predictAndUpdateState(net,YTrain(:,end));
numTimeStepsTest = size(XTest,2);
for i = 2:numTimeStepsTest
[net,YPred(:,i)] = predictAndUpdateState(net,YPred(:,i-1),'ExecutionEnvironment','cpu');
end
YPred = sig.*YPred + mu;
YTest = dataTest(:, 2:end);
rmse = sqrt(mean((YPred-YTest).^2, 2))
Asvin Kumar
2020 年 1 月 14 日
Looking at the code and our dataset size, I would suggest you to decrease the number of hidden units. The dataset used in the example has 498 time steps while yours only has 150.
This still doesn't explain why the network didn't overfit. For that, I'd suggest you try tweaking with the learning rate periods and drop factor.
It's hard to provide further insights without looking at the data.
Sharan Magavi
2020 年 1 月 15 日
Thank you for the suggestion ashvin, I thought as much that maybe I need to make some changes with the hyperparameters.
Sharan Magavi
2020 年 1 月 15 日
Also Ashvin, How would you suggest to go about merging the regression and classfication of sequences into an LSTM network?
To clarify - the data i'm using is about vehicles at a roundabout so the prediction of position has to be done to determine the position of the vehicle simultenously I need to classify which exit the vehicle might take. Right now my approach is to develop 2 networks ( 1 for position prediction and the other for classification of exits). Is there a way like an esemble or a better architecture to have a single network for this application?
Thanks!
Asvin Kumar
2020 年 1 月 16 日
Sharan Magavi
2020 年 1 月 16 日
Hello Ashvin,
I was able to solve the problem I had with the prediction. I used an 'sgdm' solver instead of an adam solver and it made a big difference in my output.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Deep Learning Toolbox についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
