CNN error using deep network designer

Hi,
i trying to combine certain part of the two CNN into one model using addition layer. However, there seem to be error while analyzing the combined models using deep network designer.
Thank you.

 采纳的回答

Hi Teo,
As you already noticed, the shufflenet branch results in 544 channels and the resnet18 branch results in 512 channels. You could map one of those branches (e.g. shufflenet branch) to the number of filters of the other branch (e.g. resnet18) by using a convolution2dLayer with filter size [1 1] and 512 filters. Then you should be able to do the addition.
I don't know the details of what you're doing and what the two branches are supposed to do, but I wonder if a concatenationLayer would be the better choice here to combine the two branches.
I hope this helps.
Katja

3 个评论

Regarding question 1) If you're asking about the Padding, you can leave it at all zeros. Because the filter size is [1,1], the convolution operation will not reduce the spatial size of the activations. Therefore, no padding is needed. You can also choose the option "same" in the drop-down, which will ensure that the spatial size of the output is the same as the input. In this case, this also means padding 0.
Regarding question 2) The addition layer will sum the activations of the two branches:Y_add = Y_node198 + Y_res5b. So the output, Y_add has the same size as Y_node198 and Y_res5b.
The concatenation layer will keep both sets of activations as is and just append them to each other to form a larger activation with all feature maps combined. So the number of feature maps in the resulting activation is the sum of the number of feature maps of Y_node198 and Y_res5b.
You can see these two effects when looking at the Activations size in the analyzeNetwork app.
I would say addition is typically used in resnet-style networks in so-called skip connections to make sure the gradients flow better/further through the network which allows for training of deeper networks. The concatenation operation makes more sense when several parts of the network compute different kinds of feature maps and you want to take all these features into account when making the final decision.
I hope this helps.
The activations of the layers in your network are four-dimensional: Height-by-Width-by-NumChannels-by-MiniBatchSize. To configure the layer, you need to tell it over which of those dimensions you want to concatenate. In your case, you want to combine the channels of the inputs. The channels are in the third dimension of the activations. So in this scenario, Dim would be 3.
The layer basically executes MATLAB's cat function. If you're interested in more details, the examples shown in the cat reference page might provide a better understanding of the concatenation operation. The example with the 3D array is closest to what happens in the convolutional neural network.
I really appreciate your suggestion and clarification on the confusion. Thank you very much.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Install Products 的更多信息

产品

版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by