Using LSTM for non-linear system identification
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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:
- 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
- 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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!