pub struct ViTConfig {
pub img_size: usize,
pub patch_size: usize,
pub in_chans: usize,
pub embed_dim: usize,
pub depth: usize,
pub n_heads: usize,
pub mlp_ratio: usize,
pub n_classes: usize,
}Expand description
Top-level ViT configuration.
Fields§
§img_size: usizeSquare spatial resolution of the input image (H = W).
patch_size: usizePatch size (stride = kernel size = patch_size).
in_chans: usizeNumber of input channels (e.g. 3 for RGB).
embed_dim: usizeToken embedding dimension.
depth: usizeNumber of transformer blocks.
n_heads: usizeNumber of attention heads per block.
mlp_ratio: usizeMLP hidden-dim multiplier.
n_classes: usizeNumber of output classes for the classification head.
Implementations§
Source§impl ViTConfig
impl ViTConfig
Sourcepub fn tiny() -> Self
pub fn tiny() -> Self
Tiny ViT: suitable for CIFAR-10 style 32×32 RGB images.
img_size=32, patch_size=4, in_chans=3, embed_dim=64,
depth=2, n_heads=4, mlp_ratio=4, n_classes=10.
Sourcepub fn new(
img_size: usize,
patch_size: usize,
in_chans: usize,
embed_dim: usize,
depth: usize,
n_heads: usize,
mlp_ratio: usize,
n_classes: usize,
) -> VisionResult<Self>
pub fn new( img_size: usize, patch_size: usize, in_chans: usize, embed_dim: usize, depth: usize, n_heads: usize, mlp_ratio: usize, n_classes: usize, ) -> VisionResult<Self>
Validate and construct a ViTConfig.
§Errors
n_classes == 0→InvalidNumClasses- patch or image size issues → propagated from
PatchEmbedConfig embed_dim % n_heads != 0→HeadDimMismatch
Trait Implementations§
impl StructuralPartialEq for ViTConfig
Auto Trait Implementations§
impl Freeze for ViTConfig
impl RefUnwindSafe for ViTConfig
impl Send for ViTConfig
impl Sync for ViTConfig
impl Unpin for ViTConfig
impl UnsafeUnpin for ViTConfig
impl UnwindSafe for ViTConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more