class

ML::NN::ViTEncoder

Inherits Reference / Object

Full Vision Transformer Encoder

Constructors

new(img_size : Int32 = 224, patch_size : Int32 = 16, in_channels : Int32 = 3, embed_dim : Int32 = 768, depth : Int32 = 12, num_heads : Int32 = 12, mlp_ratio : Float32 = 4.0_f32, dropout : Float32 = 0.0_f32, device : Tensor::Device = Tensor.default_device)
Source

Instance methods

blocks
Source
call(x : Autograd::Variable) : Autograd::Variable
Source
cls_token

Learnable parameters

Source
forward(x : Autograd::Variable) : Autograd::Variable

Forward: Image -> Sequence of embeddings x: [batch, channels, height, width] Returns: [batch, num_patches + 1, embed_dim] (includes CLS token)

Source
forward_cls(x : Autograd::Variable) : Autograd::Variable

Get CLS token output (for classification)

Source
norm
Source
parameters
Source
patch_embed
Source
pos_embed
Source