Could anyone please help me with an example of LSTM network matlab code.

2 views (last 30 days)
numFeatures = 12;
numHiddenUnits1 = 125;
numHiddenUnits2 = 100;
numClasses = 9;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits1,'OutputMode','sequence')
dropoutLayer(0.2)
lstmLayer(numHiddenUnits2,'OutputMode','last')
dropoutLayer(0.2)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
  1 Comment
Steven Lord
Steven Lord on 11 Jun 2021
That appears to be the last example in the "Deeper LSTM Networks" subsection on this documentation page. Since you've found that page it's not clear what type of help you're looking for. Please explain what you want in more detail.

Sign in to comment.

Answers (3)

jaah navi
jaah navi on 11 Jun 2021
As I am not clear with LSTM time series in the matlab code, i need a clear explanation with a sample matlab code that can perform time series using LSTM.

Steven Lord
Steven Lord on 11 Jun 2021
One of the "Related Topics" listed at the end of the documentation page to which I linked in my comment on the question is "Time Series Forecasting Using Deep Learning". Is the process described on that page what you mean by "perform time series using LSTM"? If you don't want to use the time series data to forecast the values of your series at future times, what do you want to do?

jaah navi
jaah navi on 11 Jun 2021
Actually i want to implement LSTM in my deep neural network code. when I tried using the above commands in my code I am getting error stating Undefined function or variable 'sequenceInputLayer'. As I am not having indepth knowledge of LSTM I am unable to solve the error.
Could you please help me to solve it.
  1 Comment
Steven Lord
Steven Lord on 11 Jun 2021
Please don't post comments responding to an answer as answers themselves. Post them as comments, like I did here.
You did not mention in your original message that you were receiving an error.
Do you have Deep Learning Toolbox installed? You can check the output of the ver function to determine this. Since sequenceInputLayer is part of that product if you don't have the toolbox installed and licensed you will not be able to use it.
which sequenceInputLayer
/MATLAB/toolbox/nnet/cnn/sequenceInputLayer.m
Which release of MATLAB are you using? The ver function will also show you this.

Sign in to comment.

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!