Shortcuts

MAEPretrainHead

class mmpretrain.models.heads.MAEPretrainHead(loss, norm_pix=False, patch_size=16, in_channels=3)[源代码]

Head for MAE Pre-training.

参数:
  • loss (dict) – Config of loss.

  • norm_pix_loss (bool) – Whether or not normalize target. Defaults to False.

  • patch_size (int) – Patch size. Defaults to 16.

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

construct_target(target)[源代码]

Construct the reconstruction target.

In addition to splitting images into tokens, this module will also normalize the image according to norm_pix.

参数:

target (torch.Tensor) – Image with the shape of B x C x H x W

返回:

Tokenized images with the shape of B x L x C

返回类型:

torch.Tensor

loss(pred, target, mask)[源代码]

Generate loss.

参数:
返回:

The reconstruction loss.

返回类型:

torch.Tensor

patchify(imgs)[源代码]

Split images into non-overlapped patches.

参数:

imgs (torch.Tensor) – A batch of images. The shape should be \((B, C, H, W)\).

返回:

Patchified images. The shape is \((B, L, \text{patch_size}^2 \times C)\).

返回类型:

torch.Tensor

unpatchify(x)[源代码]

Combine non-overlapped patches into images.

参数:

x (torch.Tensor) – The shape is \((B, L, \text{patch_size}^2 \times C)\).

返回:

The shape is \((B, C, H, W)\).

返回类型:

torch.Tensor

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.