CvTConfig
ModelConfigCvTConfig(num_classes: int = 1000, in_channels: int = 3, variant: str = 'cvt_13', dims: tuple[int, ...] = (64, 192, 384), depths: tuple[int, ...] = (1, 2, 10), num_heads: tuple[int, ...] = (1, 3, 6), embed_strides: tuple[int, ...] = (4, 2, 2), mlp_ratio: float = 4.0, dropout: float = 0.0, cls_token: tuple[bool, ...] = (False, False, True))Configuration dataclass for every CvT variant.
CvTConfig is an immutable container that fully specifies the
architecture of a Convolutional Vision Transformer (Wu et al.,
2021). CvT replaces plain ViT's non-overlapping patch embedding
with overlapping convolutional token embedding at each of three
stages, and replaces the linear Q/K/V projections inside every
self-attention with depthwise-separable convolutional projections.
Parameters
num_classesint= 10001000 (ImageNet-1k).in_channelsint= 33 (RGB).variantstr= 'cvt_13'"cvt_13", "cvt_21", "cvt_w24"). Defaults to
"cvt_13".dimstuple of int= (64, 192, 384)(64, 192, 384) (CvT-13).depthstuple of int= (1, 2, 10)(1, 2, 10) (CvT-13).num_headstuple of int= (1, 3, 6)(1, 3, 6)
(CvT-13).embed_stridestuple of int= (4, 2, 2)(4, 2, 2) — total downsampling 16x.mlp_ratiofloat= 4.04.0.dropoutfloat= 0.00.0.Attributes
model_typeClassVar[str]"cvt" used by the model registry.Notes
The canonical variants registered as factory functions in
lucid.models.vision.cvt are:
=========== ==================== ============== =============== Variant dims depths num_heads =========== ==================== ============== =============== CvT-13 (64, 192, 384) (1, 2, 10) (1, 3, 6) CvT-21 (64, 192, 384) (1, 4, 16) (1, 3, 6) CvT-W24 (192, 768, 1024) (2, 2, 20) (3, 12, 16) =========== ==================== ============== ===============
Reference: Haiping Wu et al., "CvT: Introducing Convolutions to Vision Transformers", ICCV 2021, arXiv:2103.15808.
Examples
Build a CvT-13 configuration with a 10-class head:
>>> from lucid.models.vision.cvt import CvTConfig
>>> cfg = CvTConfig(num_classes=10)
>>> cfg.dims, cfg.depths, cfg.num_heads, cfg.num_classes
((64, 192, 384), (1, 2, 10), (1, 3, 6), 10)Used by 3
Constructors
1__init__
→None__init__(num_classes: int = 1000, in_channels: int = 3, variant: str = 'cvt_13', dims: tuple[int, ...] = (64, 192, 384), depths: tuple[int, ...] = (1, 2, 10), num_heads: tuple[int, ...] = (1, 3, 6), embed_strides: tuple[int, ...] = (4, 2, 2), mlp_ratio: float = 4.0, dropout: float = 0.0, cls_token: tuple[bool, ...] = (False, False, True))