basecls.models.resnet#

ResNet Series

ResNet: “Deep Residual Learning for Image Recognition”

ResNet-D: “Bag of Tricks for Image Classification with Convolutional Neural Networks”

ResNeXt: “Aggregated Residual Transformations for Deep Neural Networks”

Se-ResNet: “Squeeze-and-Excitation Networks”

Wide ResNet: “Wide Residual Networks”

引用

facebookresearch/pycls facebookresearch/pycls

class basecls.models.resnet.ResBasicBlock(w_in, w_out, stride, bot_mul, se_r, avg_down, drop_path_prob, norm_name, act_name, **kwargs)[源代码]#

基类:Module

Residual basic block: x + f(x), f = [3x3 conv, BN, Act] x2.

forward(x)[源代码]#
class basecls.models.resnet.ResBottleneckBlock(w_in, w_out, stride, bot_mul, group_w, se_r, avg_down, drop_path_prob, norm_name, act_name, **kwargs)[源代码]#

基类:Module

Residual bottleneck block: x + f(x), f = 1x1, 3x3, 1x1 [+SE].

forward(x)[源代码]#
class basecls.models.resnet.ResDeepStem(w_in, w_out, norm_name, act_name, **kwargs)[源代码]#

基类:Module

ResNet-D stem: [3x3, BN, Act] x3, MaxPool.

forward(x)[源代码]#
class basecls.models.resnet.ResStem(w_in, w_out, norm_name, act_name, **kwargs)[源代码]#

基类:Module

ResNet stem: 7x7, BN, Act, MaxPool.

forward(x)[源代码]#
class basecls.models.resnet.SimpleStem(w_in, w_out, norm_name, act_name, **kwargs)[源代码]#

基类:Module

Simple stem: 3x3, BN, Act.

forward(x)[源代码]#
class basecls.models.resnet.AnyStage(w_in, w_out, stride, depth, block_func, drop_path_prob, **kwargs)[源代码]#

基类:Module

AnyNet stage (sequence of blocks w/ the same output shape).

forward(x)[源代码]#
class basecls.models.resnet.ResNet(stem_name, stem_w, block_name, depths, widths, strides, bot_muls=1.0, group_ws=None, se_r=0.0, avg_down=False, drop_path_prob=0.0, zero_init_final_gamma=False, norm_name='BN', act_name='relu', head=None)[源代码]#

基类:Module

ResNet model.

参数
  • stem_name (Union[str, Callable]) – stem name.

  • stem_w (int) – stem width.

  • block_name (Union[str, Callable]) – block name.

  • depths (Sequence[int]) – depth for each stage (number of blocks in the stage).

  • widths (Sequence[int]) – width for each stage (width of each block in the stage).

  • strides (Sequence[int]) – strides for each stage (applies to the first block of each stage).

  • bot_muls (Union[float, Sequence[float]]) – bottleneck multipliers for each stage (applies to bottleneck block). Default: 1.0

  • group_ws (Optional[Sequence[int]]) – group widths for each stage (applies to bottleneck block). Default: None

  • se_r (float) – Squeeze-and-Excitation (SE) ratio. Default: 0.0

  • drop_path_prob (float) – drop path probability. Default: 0.0

  • zero_init_final_gamma (bool) – enable zero-initialize or not. Default: False

  • norm_name (str) – normalization function. Default: "BN"

  • act_name (str) – activation function. Default: "relu"

  • head (Optional[Mapping[str, Any]]) – head args. Default: None

forward(x)[源代码]#
static get_stem_func(name)[源代码]#

Retrieves the stem function by name.

static get_block_func(name)[源代码]#

Retrieves the block function by name.