basecls.models.resmlp#

ResMLP Series

ResMLP: “ResMLP: Feedforward networks for image classification with data-efficient training”

引用

facebookresearch/deit

class basecls.models.resmlp.Affine(dim)[源代码]#

基类:Module

ResMLP Affine Layer.

forward(x)[源代码]#
class basecls.models.resmlp.ResMLPBlock(dim, drop, drop_path, num_patches, init_scale, ffn_ratio, act_name)[源代码]#

基类:Module

ResMLP block.

参数
  • dim (int) – Number of input channels.

  • drop (float) – Dropout ratio.

  • drop_path (float) – Stochastic depth rate.

  • num_patches (int) – Number of patches.

  • init_scale (float) – Initial value for LayerScale.

  • ffn_ratio (float) – Ratio of ffn hidden dim to embedding dim.

  • act_name (str) – activation function.

forward(x)[源代码]#
class basecls.models.resmlp.ResMLP(img_size=224, patch_size=16, in_chans=3, embed_dim=768, depth=12, drop_rate=0.0, drop_path_rate=0.0, embed_layer=PatchEmbed, init_scale=1e-4, ffn_ratio=4.0, act_name='gelu', num_classes=1000, **kwargs)[源代码]#

基类:Module

ResMLP model.

参数
  • img_size (int) – Input image size. Default: 224

  • patch_size (int) – Patch token size. Default: 16

  • in_chans (int) – Number of input image channels. Default: 3

  • embed_dim (int) – Number of linear projection output channels. Default: 768

  • depth (int) – Depth of Transformer Encoder layer. Default: 12

  • drop_rate (float) – Dropout rate. Default: 0.0

  • drop_path_rate (float) – Stochastic depth rate. Default: 0.0

  • embed_layer (Module) – Patch embedding layer. Default: PatchEmbed

  • init_scale (float) – Initial value for LayerScale. Default: 1e-4

  • ffn_ratio (float) – Ratio of ffn hidden dim to embedding dim. Default: 4.0

  • act_name (str) – Activation function. Default: "gelu"

  • num_classes (int) – Number of classes. Default: 1000

forward(x)[源代码]#