Using LSTM for non-linear system identification

4 visualizaciones (últimos 30 días)
David Vatavu
David Vatavu el 12 de Nov. de 2023
Respondida: Gagan Agarwal el 24 de Nov. de 2023
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 comentarios
KSSV
KSSV el 13 de Nov. de 2023
You need to attach your input data. Attach the mat file.
David Vatavu
David Vatavu el 13 de Nov. de 2023
Are you sure? What do you think about creating the neural network?

Iniciar sesión para comentar.

Respuesta aceptada

Gagan Agarwal
Gagan Agarwal el 24 de Nov. de 2023
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!

Más respuestas (0)

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by