Shortcuts

RepLKNet

class mmpretrain.models.backbones.RepLKNet(arch, in_channels=3, ffn_ratio=4, out_indices=(3,), strides=(2, 2, 2, 2), dilations=(1, 1, 1, 1), frozen_stages=-1, conv_cfg=None, norm_cfg={'type': 'BN'}, act_cfg={'type': 'ReLU'}, with_cp=False, drop_path_rate=0.3, small_kernel_merged=False, norm_intermediate_features=False, norm_eval=False, init_cfg=[{'type': 'Kaiming', 'layer': ['Conv2d']}, {'type': 'Constant', 'val': 1, 'layer': ['_BatchNorm', 'GroupNorm']}])[source]

RepLKNet backbone.

A PyTorch impl of : Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs

Parameters:
  • arch (str | dict) –

    The parameter of RepLKNet. If it’s a dict, it should contain the following keys:

    • large_kernel_sizes (Sequence[int]):

      Large kernel size in each stage.

    • layers (Sequence[int]): Number of blocks in each stage.

    • channels (Sequence[int]): Number of channels in each stage.

    • small_kernel (int): size of the parallel small kernel.

    • dw_ratio (float): The intermediate channels

      expansion ratio of the block.

  • in_channels (int) – Number of input image channels. Default to 3.

  • ffn_ratio (float) – Mlp expansion ratio. Defaults to 4.

  • out_indices (Sequence[int]) – Output from which stages. Default to (3, ).

  • strides (Sequence[int]) – Strides of the first block of each stage. Default to (2, 2, 2, 2).

  • dilations (Sequence[int]) – Dilation of each stage. Default to (1, 1, 1, 1).

  • frozen_stages (int) – Stages to be frozen (all param fixed). -1 means not freezing any parameters. Default to -1.

  • conv_cfg (dict | None) – The config dict for conv layers. Default to None.

  • norm_cfg (dict) – The config dict for norm layers. Default to dict(type='BN').

  • act_cfg (dict) – Config dict for activation layer. Default to dict(type='ReLU').

  • with_cp (bool) – Use checkpoint or not. Using checkpoint will save some memory while slowing down the training speed. Default to False.

  • deploy (bool) – Whether to switch the model structure to deployment mode. Default to False.

  • norm_intermediate_features (bool) – Construct and config norm layer or not. Using True will normalize the intermediate features for downstream dense prediction tasks.

  • norm_eval (bool) – Whether to set norm layers to eval mode, namely, freeze running stats (mean and var). Note: Effect on Batch Norm and its variants only. Default to False.

  • init_cfg (dict or list[dict], optional) – Initialization config dict.