How to define input data format string in Stateful Predict block for dlnetwork when input is N x 3 array (3 Channels, N measured data points)?

7 次查看(过去 30 天)
Hello,
i trained a LSTM network (sequence to sequence regression) using trainnet.
As an example, I have simplified my code below. The code provides a trained dlnetwork that I have saved under the name test_LSTM.mat. I would now like to load the dlnetwork into the stateful predict block in Simulink. To do this, I have to specify the format as shown in the picture. The input is an array consisting of three vectors/columns. Each column contains n measurement points. The output of the network is a vector of length n. I found the following help page:
https://de.mathworks.com/help/deeplearning/ref/statefulpredict.html
I have tried different combinations. I do not understand the necessary formatting nor do I know which letters to use in my case ?
X = [in1 in2 in3];
Y = out1;
...
layers = [
sequenceInputLayer(3,"Name","input")
lstmLayer(params.numHiddenUnits,"Name","lstm",OutputMode="sequence")
fullyConnectedLayer(params.fullyConnectedLayer, "Name", "fclayer");
dropoutLayer(params.dropoutLayer, "Name", "doutlayer");
fullyConnectedLayer(1,"Name", "output")];
...

回答(1 个)

Adarsh
Adarsh 2025-2-20
I see that you are trying to use the “Stateful Predict” Simulink block to make predictions with a trained “dlnetwork” (LSTM). The Format field in the Input data formats section must be filled with a string based on the type of input given to the block.
The string must be a combination of characters representing type of each input dimension as shown:
“S” – Spatial
“C” – Channel
“B” – Batch
“T” – Time
“U” – Unspecified
For example, consider an array containing a batch of sequences where the first, second, and third dimensions correspond to channels, observations, and time steps, respectively. You can specify that this array has the format "CBT" (channel, batch, time).
Given that the input size is Nx3 array, I assume the first dimension consists of Time Steps and 3 is the number of channels present. Hence the input data format must be “TC”.
To get a better understanding on how various input data formats work you can refer to the following documentation links:
  1. https://www.mathworks.com/help/deeplearning/ug/deep-learning-data-formats.html
  2. https://www.mathworks.com/help/R2023b/deeplearning/ref/statefulpredict.html
I hope this helps.

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by