MATLAB Answers

sequence learning using LSTM

12 views (last 30 days)
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


Sign in to comment.

Accepted Answer

Asvin Kumar
Asvin Kumar on 30 Dec 2019
Edited: Asvin Kumar on 30 Dec 2019
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.


Show 8 older comments
Sharan Magavi
Sharan Magavi on 15 Jan 2020
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?
Sharan Magavi
Sharan Magavi on 16 Jan 2020
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.

Sign in to comment.

More Answers (0)

Sign in to answer this question.