Neural Network in ST Edge AI Developer Cloud Error Shape and shape map lengths must be the same
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Silvia
am 21 Okt. 2024
Kommentiert: Silvia
am 24 Okt. 2024
Hello everyone,
I would like to test the ST Edge AI Developer Cloud with a neural network that I trained using MATLAB.
My architecture is the following:
layers = [
sequenceInputLayer(1, 'Name', 'input')
convolution1dLayer(8, 10, 'Padding', 'same', 'Name', 'conv1')
batchNormalizationLayer('Name', 'batchnorm1')
reluLayer('Name', 'relu1')
gruLayer(32, 'OutputMode', 'sequence', 'Name', 'gru1')
fullyConnectedLayer(1, 'Name', 'output')
];
When I load my model into the STM tool, I get the following error: TOOL ERROR: Shape and shape map lengths must be the same: [96] vs. (CH_IN, CH). I wondered if it was due to an error on my part in the network structure.
Thank you in advance,
Silvia
0 Kommentare
Akzeptierte Antwort
Subhajyoti
am 22 Okt. 2024
Bearbeitet: Subhajyoti
am 22 Okt. 2024
Hi @Silvia
The error you are encountering, “TOOL ERROR: Shape and shape map lengths must be the same: [96] vs. (CH_IN, CH)” indicates a mismatch between the input and expected shapes in the STM tool, which is generally sensitive to input dimensions and layer compatibility.
Here, in the following implementation, I have used a random sequence of length 96 (since the error mentioned 96) as synthetic data point to test the layer compatibility in the architecture.
% Define your layers in the dlnetwork format
layers = [
sequenceInputLayer(1, 'Name', 'input')
convolution1dLayer(8, 10, 'Padding', 'same', 'Name', 'conv1')
batchNormalizationLayer('Name', 'batchnorm1')
reluLayer('Name', 'relu1')
gruLayer(32, 'OutputMode', 'sequence', 'Name', 'gru1')
fullyConnectedLayer(1, 'Name', 'output')
]
% Create the dlnetwork object
net = dlnetwork(layerGraph(layers));
% Sample input data point: Sequence of length 96 with 1 feature
sequenceLength = 96;
inputData = rand(sequenceLength, 1); % Random sequence with 96 time steps and 1 feature
% Convert input to a dlarray with the format 'CBT' (Channel, Batch, Time)
dlInputData = dlarray(inputData', 'CBT');
% Make prediction using the dlnetwork object
predictedOutput = predict(net, dlInputData)
The above code output indicates that the input and output shapes work correctly. Hence, the error might be arising due to incorrect model input size.
You can refer to the following MathWorks documentation links to learn more about ‘Deep Learning Networks Architectures’ in MATLAB:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!