pub struct VisionTransformerConfig {
pub patch_embed: PatchEmbeddingConfig,
pub encoder: EncoderStackConfig,
pub num_classes: usize,
pub use_class_token: bool,
pub classifier_dropout: f64,
}Expand description
Configuration for Vision Transformer
Fields§
§patch_embed: PatchEmbeddingConfigPatch embedding configuration
encoder: EncoderStackConfigTransformer encoder stack configuration
num_classes: usizeNumber of output classes
use_class_token: boolWhether to use class token
classifier_dropout: f64Dropout rate for classification head
Implementations§
Source§impl VisionTransformerConfig
impl VisionTransformerConfig
Sourcepub fn new(
image_size: usize,
patch_size: usize,
in_channels: usize,
d_model: usize,
n_heads: usize,
d_ff: usize,
n_layers: usize,
num_classes: usize,
) -> Result<Self>
pub fn new( image_size: usize, patch_size: usize, in_channels: usize, d_model: usize, n_heads: usize, d_ff: usize, n_layers: usize, num_classes: usize, ) -> Result<Self>
Create new Vision Transformer configuration
Sourcepub fn with_class_token(self, use_class_token: bool) -> Self
pub fn with_class_token(self, use_class_token: bool) -> Self
Builder: Set whether to use class token
Sourcepub fn with_classifier_dropout(self, dropout: f64) -> Self
pub fn with_classifier_dropout(self, dropout: f64) -> Self
Builder: Set classifier dropout
Sourcepub fn with_learned_position_encoding(self) -> Self
pub fn with_learned_position_encoding(self) -> Self
Builder: Set learned position encoding
Sourcepub fn with_pre_norm(self, pre_norm: bool) -> Self
pub fn with_pre_norm(self, pre_norm: bool) -> Self
Builder: Set whether to use pre-norm
Sourcepub fn with_dropout(self, dropout: f64) -> Self
pub fn with_dropout(self, dropout: f64) -> Self
Builder: Set dropout
Sourcepub fn seq_length(&self) -> usize
pub fn seq_length(&self) -> usize
Get sequence length (num_patches + optional class token)
Trait Implementations§
Source§impl Clone for VisionTransformerConfig
impl Clone for VisionTransformerConfig
Source§fn clone(&self) -> VisionTransformerConfig
fn clone(&self) -> VisionTransformerConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for VisionTransformerConfig
impl RefUnwindSafe for VisionTransformerConfig
impl Send for VisionTransformerConfig
impl Sync for VisionTransformerConfig
impl Unpin for VisionTransformerConfig
impl UnwindSafe for VisionTransformerConfig
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