I have problem using the simulink block obtained from LSTM trained network. The following is the error. number of inputs to be used is 2 and number of ouputs is 1

Error:Layer "sequenceinput": Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 2 but received input with size 1.
Function 'Subsystem/Stateful Predict/MLFB' (#218.166.365), line 5, column 19:
"deep.blocks.internal.sequenceNetworkPredict({in_1}, {size(in_1)}, {class(in_1)},"
Errors occurred during parsing of 'neural_network_deep/Subsystem/Stateful Predict/MLFB'.
Component:MATLAB Function | Category:Coder error
Simulink unable to determine sizes and/or types of the outputs for block 'neural_network_deep/Subsystem/Stateful Predict/MLFB' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:MATLAB Function | Category:Coder error
Simulink unable to determine sizes and/or types of the outputs for block 'neural_network_deep/Subsystem/Stateful Predict/MLFB' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:Simulink | Category:Model error
Error in port widths or dimensions. 'Output Port 1' of 'neural_network_deep/Subsystem/Stateful Predict/MLFB/in_1' is a one dimensional

6 Comments

This could be due to how the Inport connected to the block is configured. Could you share your model and any related files?
Hi, thanks for the reply.
i have used the below program to train the network using LSTM.
xtrain=xlsread("train_elm.xlsx",1,'A1:B12000')';
ytrain=xlsread("train_elm.xlsx",1,'C1:C12000')';
xtest=xlsread("test_elm.xlsx",1,'A1:B3000')';
ytest=xlsread("test_elm.xlsx",1,'C1:C3000')';
ip_size=[1 2];
responses=[1];
numHiddenUnits=100;
numFeatures = numel(ip_size);
numResponses = numel(responses);
layers=[sequenceInputLayer(numFeatures)
flattenLayer
lstmLayer(numHiddenUnits)
flattenLayer
fullyConnectedLayer(numResponses)
regressionLayer];
opts=trainingOptions("adam",...
MaxEpochs=1000, ...
GradientThreshold=0.01, ...
InitialLearnRate=0.0001);
net=trainNetwork(xtrain,ytrain,layers,opts);
yperd1=predict(net,xtest)
figure
plot(yperd1,'r--','LineWidth',1)
hold on
plot(ytest,'g-*','LineWidth',1)
hold all
xlabel('sample')
ylabel('values')
grid on
legend('predicted','original')
title('performance')
deepNetworkDesigner(net)
The network obtained is used in the above model.
This produces errorError:Layer "sequenceinput": Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 2 but received input with size 1.
Function 'Subsystem/Stateful Predict/MLFB' (#205.166.369), line 5, column 19:
"deep.blocks.internal.sequenceNetworkPredict({in_1}, {size(in_1)}, {class(in_1)},"
Launch diagnostic report.
Please share the Simulink model as an attachment along with the training data (Excel files).
the net was exported to simulink using export to simulink in deep network designer app.

Sign in to comment.

Answers (1)

Hi Sowmya,
I understand that you are facing the error "Error:Layer "sequenceinput": Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 2 but received input with size 1." while training a recurrent network.
The reason for the error is that the network excepts 2 sequences of inputs, but you are providing only 1 sequence to the 'sequenceInputLayer.' Please also ensure that training and vaildation data has consistent dimension to avoid these kinds of errors.
Please look at the below documentation to learn more regarding this,
Also please look at the below documentation on how to train a recurrent neural network using 'dlnetwork.'
Hope this helps.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Asked:

on 17 Dec 2024

Answered:

on 28 Jan 2025

Community Treasure Hunt

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

Start Hunting!