Is it possible to use a three-dimensional matrix to train LSTM network in Matlab R2020b?

2 views (last 30 days)
Hello everyone,
Previously I trained the neural networks with the trainNetwork(XTrain0',YTrain',layers0,options), with XTrain0 as the input variables, expressed as a (7670 x 7) array, and the YTrain as the output variable that I would like to predict in the future, expressed as a (7670 x 1) array. The result looks good..
However, I currently have difficulty on training the LSTM network with 3-dimensional input data. I want to determine the details fo the original input data variable by breaking them into 139 segments. Originally I tried to use (1058460 x 7) array and (1058460 x 1) array as inputs, but the result of prediction was highly inaccurate.
and I tried to test whether I can do it by creating 3-dimensional variables: the input ends up looking like (7670 x 7 x 139) array and the input is (7670 x 1 x 139) array, but I have difficulty on rewriting the network (layers0). Here is my original modified version of layers0:
layers0 = [ ...
sequenceInputLayer([7,139,1])
lstmLayer(100,'OutputMode','sequence')
fullyConnectedLayer(1)
dropoutLayer(0.4)
regressionLayer];
I tried to look up every page of MATLAB but cannot find the solution. Please help me improve my layers0 so that I can input my 3-dimensional variables. Thank you.
  3 Comments
Pai-Feng Teng
Pai-Feng Teng on 5 Apr 2021
If you input sequence layer in the format of 3-dimensional, they will tell you that it must be scalar.
I look up the internet and I can't find any code with sequenceInputLayer that accepts 3D inputs
Aditya Patil
Aditya Patil on 6 Apr 2021
Here is an example for 3D input, https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sequenceinputlayer.html#mw_d1a76588-f98f-4d19-9130-d4411b4a5ee9

Sign in to comment.

Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!