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
0 个评论
采纳的回答
Subhajyoti
2024-10-22,10:39
编辑:Subhajyoti
2024-10-22,10:41
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:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!