Does resnet have fully connected layers?
Asked Answered
H

2

6

In my understanding, fully connected layer(fc in short) is used for predicting.

For example, VGG Net used 2 fc layers, which are both 4096 dimension. The last layer for softmax has dimension same with classes num:1000.

VGG net

But for resnet, it used global average pooling, and use the pooled result of last convolution layer as the input.

resnet

But they still has a fc layer! Does this layer a really fc layer? Or this layer is only to make input into a vector of features which number is classes number? Does this layer has function for prediction result?

In a word, how many fc layers do resnet and VGGnet have? Does VGGnet's 1st 2nd 3rd fc layer has different function?

Hassan answered 5/7, 2017 at 11:51 Comment(0)
M
3

VGG has three FC layers, two with 4096 neurons and one with 1000 neurons which outputs the class probabilities.

ResNet only has one FC layer with 1000 neurons which again outputs the class probabilities. In a NN classifier always the best choice is to use softmax, some authors make this explicit in the diagram while others do not.

Misunderstood answered 5/7, 2017 at 12:17 Comment(8)
It's misleading to call the output layer of ResNet a fully-connected layer. The output layer is a softmax layer, which unlike a fully-connected layer in VGG-16, does not have any trainable parameters.Idiotic
@FijoyVadakkumpadan No, it is not, you are incorrect, because a ResNet trained for ImageNet does have a FC layer, see some implementations: github.com/keras-team/keras/blob/…Misunderstood
While the implementation you point to has a dense layer technically, there's no need to use a dense layer there. You missed what feeds into that dense layer - a Global Average Pooling layer. That dense layer can be replaced with a 1x1 convolutional layer.Idiotic
@FijoyVadakkumpadan Irrelevant, your main argument was that the layer would have no trainable parameters, while a 1x1 conv does have trainable parameters.Misunderstood
No, my argument was that calling a softmax layer a fully connected layer is misleading. You missed that too.Idiotic
@FijoyVadakkumpadan That is also incorrect, because it is a FC layer with a softmax activation, you have not shown that it is not the case.Misunderstood
No, my original comment is really about softmax when it's mentioned as a separate layer.Idiotic
@FijoyVadakkumpadan Maybe I should remind you that the question was "Do ResNets have FC layers", not about if the last layer was divided between FC and Softmax.Misunderstood
M
3

In essence the guys at microsoft (ResNet) favor more convolutional layers instead of fully connected ones and therefore ommit fully connected layers. GlobalAveragePooling also decreases the feature size dramatically and therefore reduces the number of parameters going from the convolutional part to the fully connected part.

I would argue that the performance difference is quite slim, but one of their main accomplishments, by introducing ResNets is the dramatic reduction of parameters and those two points helped them accomplish that.

Mathian answered 5/7, 2017 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.