Predict function returns concatenation error for a two-input Deep Neural Network

4 次查看(过去 30 天)
I was successfully able to train the Two-Input Neural Network with a combined arrayDataStore with an image and a set of features.
I use a concatenation layer in my network to combined the two-input to give a single output. I was able to train successfully and also use the validation data, however when I try to predict using the arrayDataStore I get the following error:
Error using matlab.internal.math.cnn.MLFusedNetwork/predict
Arrays are not compatible for concatenation on specified axis.
I am not sure if the datastore is the issue or the somehow the concatenation layer is giving trouble when predicting.
The code and network image are attached
Layers for the Network:
Data store code:
Thank you

回答(1 个)

Ben
Ben 2023-3-16
The "Format" functionLayer is re-labelling the input as "CSSB", and the inputs are "CB", so it's going to make the batch dimension into a spatial dimension and you won't be able to concatenate that as the Fc_conv output has scalar spatial dimensions in DAGNetwork.
You could either change the format in the functionLayer to "CBSS" or move the functionLayer to the other branch and use the function @(x) dlarray(squeeze(x),"CB") to get rid of the scalar S dimensions - then you'd need to concatenate on dimension 1 rather than 3.

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by