科普知识
ResNet
mmdetection中实现此结构
arch_settings = {
18: (BasicBlock, (2, 2, 2, 2)),
34: (BasicBlock, (3, 4, 6, 3)),
50: (Bottleneck, (3, 4, 6, 3)),
101: (Bottleneck, (3, 4, 23, 3)),
152: (Bottleneck, (3, 8, 36, 3))
}
# 注意BasicBlock Bottleneck均为一个类
RestNet 18/34采用BasicBlock作为基本单元,而ResNet 50/101/152采用Bottlenet Block作为基本单元
Basic Block就是左边的图,包括两个3×3的卷积操作。bollteneck是右边的图,为了减少参数,它采用了两个1×1的卷积。
参数解读
""ResNet backbone.
Args:
depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. ResNet深度,总所周知,常用的为50,101
stem_channels (int | None): Number of stem channels. If not specified,
it will be the same as `base_channels`. Default: None.
base_channels (int): Number of base channels of res layer. Default: 64. 众所周知,这个为64详情见Resnet Conv1
in_channels (int): Number of input image channels. Default: 3.众所周知
num_stages (int): Resnet stages. Default: 4.众所周知 详情见conv1_x conv2_x .......称为一个stage
strides (Sequence[int]): Strides of the first block of each stage.众所周知 每个stage第一个block的步长
dilations (Sequence[int]): Dilation of each stage.众所周知,用于空洞卷积
out_indices (Sequence[int]): Output from which stages. 众所周知,每个stage的输出
style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two ##使用的是pytorch/caffe关系到使用3*3/1*1的卷积
layer is the 3x3 conv layer, otherwise the stride-two layer is ##在步长为2时
the first 1x1 conv layer.
deep_stem (bool): Replace 7x7 conv in input stem with 3 3x3 conv ##在初始的时候即conv1使用3*3的卷积替代7*7的卷积
avg_down (bool): Use AvgPool instead of stride conv when
downsampling in the bottleneck.## 使用平均池化替代卷积下采样 H=ceil((H-F+2*P)/S+1)
frozen_stages (int): Stages to be frozen (stop grad and set eval mode).
-1 means not freezing any parameters. ##从stage4开始冻结几个stage拒绝梯度传播更新参数
norm_cfg (dict): Dictionary to construct and config norm layer.## 正则化方式
norm_eval (bool): Whether to set norm layers to eval mode, namely,## 用于测试模型时,将正则化设置为false,
freeze running stats (mean and var). Note: Effect on Batch Norm
and its variants only.
plugins (list[dict]): List of plugins for stages, each dict contains: ##扩展模块
- cfg (dict, required): Cfg dict to build plugin.## 需要扩展哪些操作,比如说dfn
- position (str, re