Neural Network in ST Edge AI Developer Cloud Error Shape and shape map lengths must be the same

47 次查看(过去 30 天)
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

采纳的回答

Subhajyoti
Subhajyoti 2024-10-22,10:39
编辑:Subhajyoti 2024-10-22,10:41
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')
]
layers =
6x1 Layer array with layers: 1 'input' Sequence Input Sequence input with 1 dimensions 2 'conv1' 1-D Convolution 10 8 convolutions with stride 1 and padding 'same' 3 'batchnorm1' Batch Normalization Batch normalization 4 'relu1' ReLU ReLU 5 'gru1' GRU GRU with 32 hidden units 6 'output' Fully Connected 1 fully connected layer
% 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)
predictedOutput =
1(C) x 96(B) x 1(T) single dlarray Columns 1 through 18 0.0081 0.0030 0.0094 0.0002 0.0027 0.0057 0.0013 0.0018 0.0036 0.0044 0.0030 0.0068 0.0021 0.0003 0.0082 0.0095 0.0032 0.0085 Columns 19 through 36 0.0092 0.0074 0.0087 0.0055 0.0087 0.0056 0.0002 0.0096 0.0055 0.0034 0.0057 0.0012 0.0089 0.0043 0.0071 0.0005 0.0044 0.0081 Columns 37 through 54 0.0066 0.0020 0.0084 0.0078 0.0090 0.0083 0.0041 0.0005 0.0005 0.0035 0.0026 0.0081 0.0023 0.0073 0.0047 0.0049 0.0014 0.0090 Columns 55 through 72 0.0071 0.0027 0.0013 0.0080 0.0078 0.0012 0.0024 0.0019 0.0074 0.0030 0.0026 0.0038 0.0000 0.0010 0.0006 0.0004 0.0023 0.0074 Columns 73 through 90 0.0052 0.0029 0.0038 0.0080 0.0025 0.0088 0.0007 0.0048 0.0059 0.0073 0.0018 0.0035 0.0093 0.0093 0.0019 0.0080 0.0034 0.0052 Columns 91 through 96 0.0017 0.0005 0.0011 0.0037 0.0079 0.0030
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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by