Neural Network in ST Edge AI Developer Cloud Error Shape and shape map lengths must be the same
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Silvia
el 21 de Oct. de 2024
Comentada: Silvia
el 24 de Oct. de 2024 a las 9:32
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 comentarios
Respuesta aceptada
Subhajyoti
el 22 de Oct. de 2024 a las 10:39
Editada: Subhajyoti
el 22 de Oct. de 2024 a las 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:
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!