data
CrossViTConfig
extends
ModelConfigCrossViTConfig(num_classes: int = 1000, in_channels: int = 3, image_size: int = 240, img_scale: tuple[float, float] = (1.0, 224.0 / 240.0), crop_scale: bool = False, patch_sizes: tuple[int, int] = (12, 16), embed_dims: tuple[int, int] = (96, 192), depths: tuple[tuple[int, int, int], ...] = ((1, 4, 0), (1, 4, 0), (1, 4, 0)), num_heads: tuple[int, int] = (3, 3), mlp_ratio: tuple[float, float, float] = (4.0, 4.0, 1.0), qkv_bias: bool = True, drop_path_rate: float = 0.0, dropout: float = 0.0, layer_norm_eps: float = 1e-06)Configuration for every paper-cited CrossViT variant.
Parameters
num_classesint= 1000Output-class count of the classification heads.
in_channelsint= 3Number of input image channels.
image_sizeint= 240Spatial side of the small-branch input. The large-branch
input is rescaled from this via
img_scale.img_scaletuple of float= (1.0, 224/240)Per-branch scale relative to
image_size — the first entry
targets the small-patch branch (always 1.0 in paper-cited
variants), the second the large-patch branch (224/240 in the
canonical recipe so the large branch consumes 224×224 from a
240×240 input).crop_scalebool= FalseMethod used to rescale the large-branch input.
False ⇒
bicubic resize to the absolute branch target (paper default);
True ⇒ center-crop.patch_sizestuple of int= (12, 16)Patch sizes for the (small, large) branches.
embed_dimstuple of int= (96, 192)Per-branch embedding dimensions (small, large).
depthstuple of tuple of int= ((1, 4, 0), (1, 4, 0), (1, 4, 0))Per-stage block counts
(N_s, N_l, N_cross) for each of the
K MultiScaleBlocks. Defaults to ((1, 4, 0)) × 3 (the
CrossViT-Ti recipe). N_cross is the number of extra
cross-attention transformer blocks the stage runs after the
single mandatory cross-attention fusion — paper-cited variants
keep this at 0.num_headstuple of int= (3, 3)Per-branch attention head counts (small, large).
mlp_ratiotuple of float= (4.0, 4.0, 1.0)MLP expansion ratios for the (small self-attn, large
self-attn, cross-attention) sub-modules within a
MultiScaleBlock.
qkv_biasbool= TrueNo description.
drop_path_ratefloat= 0.0Stochastic-depth rate, linearly scheduled across the whole
trunk (sum of all blocks across all stages).
dropoutfloat= 0.0Dropout probability inside attention + MLP modules.
layer_norm_epsfloat= 1e-6eps for every LayerNorm in the trunk (paper / timm use
1e-6; matches the reference checkpoints exactly).Used by 3
Constructors
1dunder
__init__
→None__init__(num_classes: int = 1000, in_channels: int = 3, image_size: int = 240, img_scale: tuple[float, float] = (1.0, 224.0 / 240.0), crop_scale: bool = False, patch_sizes: tuple[int, int] = (12, 16), embed_dims: tuple[int, int] = (96, 192), depths: tuple[tuple[int, int, int], ...] = ((1, 4, 0), (1, 4, 0), (1, 4, 0)), num_heads: tuple[int, int] = (3, 3), mlp_ratio: tuple[float, float, float] = (4.0, 4.0, 1.0), qkv_bias: bool = True, drop_path_rate: float = 0.0, dropout: float = 0.0, layer_norm_eps: float = 1e-06)