Understanding LSTM Sequence to Sequence Mathworks example
1 view (last 30 days)
Show older comments
Hi, in this example for a Sequence to Sequence regression LSTM there's a call to a function named "prepareDataTrain"
here's the function:
function [XTrain,YTrain] = prepareDataTrain(filenamePredictors)
dataTrain = dlmread(filenamePredictors);
numObservations = max(dataTrain(:,1));
XTrain = cell(numObservations,1);
YTrain = cell(numObservations,1);
for i = 1:numObservations
idx = dataTrain(:,1) == i;
X = dataTrain(idx,3:end)';
XTrain{i} = X;
timeSteps = dataTrain(idx,2)';
Y = fliplr(timeSteps);
YTrain{i} = Y;
end
end
the dataTrain table looks like this:
1 1 -0.0007 -0.0004 100.0 518.67 641.82 1589.70 1400.60 14.62 21.61 554.36 2388.06 9046.19 1.30 47.47 521.66 2388.02 8138.62 8.4195 0.03 392 2388 100.00 39.06
1 2 0.0019 -0.0003 100.0 518.67 642.15 1591.82 1403.14 14.62 21.61 553.75 2388.04 9044.07 1.30 47.49 522.28 2388.07 8131.49 8.4318 0.03 392 2388 100.00 39.00
1 3 -0.0043 0.0003 100.0 518.67 642.35 1587.99 1404.20 14.62 21.61 554.26 2388.08 9052.94 1.30 47.27 522.42 2388.03 8133.23 8.4178 0.03 390 2388 100.00 38.95
1 4 0.0007 0.0000 100.0 518.67 642.35 1582.79 1401.87 14.62 21.61 554.45 2388.11 9049.48 1.30 47.13 522.86 2388.08 8133.83 8.3682 0.03 392 2388 100.00 38.88
1 5 -0.0019 -0.0002 100.0 518.67 642.37 1582.85 1406.22 14.62 21.61 554.00 2388.06 9055.15 1.30 47.28 522.19 2388.04 8133.80 8.4294 0.03 393 2388 100.00 38.90
1 6 -0.0043 -0.0001 100.0 518.67 642.10 1584.47 1398.37 14.62 21.61 554.67 2388.02 9049.68 1.30 47.16 521.68 2388.03 8132.85 8.4108 0.03 391 2388 100.00 38.98
1 7 0.0010 0.0001 100.0 518.67 642.48 1592.32 1397.77 14.62 21.61 554.34 2388.02 9059.13 1.30 47.36 522.32 2388.03 8132.32 8.3974 0.03 392 2388 100.00 39.10
1 8 -0.0034 0.0003 100.0 518.67 642.56 1582.96 1400.97 14.62 21.61 553.85 2388.00 9040.80 1.30 47.24 522.47 2388.03 8131.07 8.4076 0.03 391 2388 100.00 38.97
1 9 0.0008 0.0001 100.0 518.67 642.12 1590.98 1394.80 14.62 21.61 553.69 2388.05 9046.46 1.30 47.29 521.79 2388.05 8125.69 8.3728 0.03 392 2388 100.00 39.05
What I don't understand in this function is why is flipping the timeSteps when they are correctly ordered. Could someone please explain this to me?
Thank you for your time.
0 Comments
Answers (0)
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!