Shortcuts

LinearClsHead

class mmpretrain.models.heads.LinearClsHead(num_classes, in_channels, init_cfg={'layer': 'Linear', 'std': 0.01, 'type': 'Normal'}, **kwargs)[源代码]

Linear classifier head.

参数:
  • num_classes (int) – Number of categories excluding the background category.

  • in_channels (int) – Number of channels in the input feature map.

  • loss (dict) – Config of classification loss. Defaults to dict(type='CrossEntropyLoss', loss_weight=1.0).

  • topk (int | Tuple[int]) – Top-k accuracy. Defaults to (1, ).

  • cal_acc (bool) – Whether to calculate accuracy during training. If you use batch augmentations like Mixup and CutMix during training, it is pointless to calculate accuracy. Defaults to False.

  • init_cfg (dict, optional) – the config to control the initialization. Defaults to dict(type='Normal', layer='Linear', std=0.01).

forward(feats)[源代码]

The forward process.

pre_logits(feats)[源代码]

The process before the final classification head.

The input feats is a tuple of tensor, and each tensor is the feature of a backbone stage. In LinearClsHead, we just obtain the feature of the last stage.

Read the Docs v: latest
Versions
latest
stable
mmcls-1.x
mmcls-0.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.