Using LSTM for non-linear system identification

4 ビュー (過去 30 日間)
David Vatavu
David Vatavu 2023 年 11 月 12 日
回答済み: Gagan Agarwal 2023 年 11 月 24 日
Hello, i need some steps and information to build a neural network lstm for nonlinear system identification. I have already the data set, training set and test set. This is my code, what i need to do more?Please tell me
clear all
clc
load('twotankdata.mat');
output=y;
input=u;
%normalizarea datelor de intrare
min_input = min(input);
max_input = max(input);
x_normalized=(input-min_input)/(max_input-min_input);
min_output=min(output);
max_output=max(output);
y_normalized=(output-min_output)/(max_output-min_output);
x_train=x_normalized(1:2250,:);
x_test=x_normalized(2251:3000,:);
y_train=y_normalized(1:2250,:);
y_test=y_normalized(2251:3000,:);
%Define LSTM Network Arhitecture
model=lstmLayer(100,'OutputMode','sequence','StateActivationFunction','tanh','GateActivationFunction','sigmoid');
numFeatures=size(x_train',2);
inputSize=1;
numHiddenUnits=70;
numClasses=1;
layer=[...
sequenceInputLayer(inputSize)
lstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
%softmaxLayer
regressionLayer
];
options=trainingOptions('adam',...
'ExecutionEnvironment','cpu',...
'MaxEpochs',250,...
'MiniBatchSize',27,...
'GradientThreshold',1,...
'Verbose',false,...
'Plots','training-progress');
net=trainNetwork(x_train',y_train',layer,options);
i have this error: Invalid training data. The output size (1) of the last layer does not match the response size (2250).
  2 件のコメント
KSSV
KSSV 2023 年 11 月 13 日
You need to attach your input data. Attach the mat file.
David Vatavu
David Vatavu 2023 年 11 月 13 日
Are you sure? What do you think about creating the neural network?

サインインしてコメントする。

採用された回答

Gagan Agarwal
Gagan Agarwal 2023 年 11 月 24 日
Hi David,
I understand that you are encountering an error that the output size of last layer does not match with the response size.
To address this issue, it is important to ensure that the output size of the last layer matches the size of your training output data. Please refer to the following approaches to resolve the issue:
  1. Review the dimensions of your training data and the expected output size. There might be inconsistency in dimensions between training data and the expected output size
  2. Verify the architecture of your neural network and the dimensions of each layer, especially the last layer. Ensure that the output size of the last layer matches the expected response size.
I hope it helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by