pub struct PatchEmbedding { /* private fields */ }Expand description
Patch embedding layer for Vision Transformers
Implementations§
Source§impl PatchEmbedding
impl PatchEmbedding
Sourcepub fn new(config: PatchEmbeddingConfig) -> Result<Self>
pub fn new(config: PatchEmbeddingConfig) -> Result<Self>
Create new patch embedding layer
Sourcepub fn build_patch_embed_graph(&self, graph: &mut EinsumGraph) -> Result<usize>
pub fn build_patch_embed_graph(&self, graph: &mut EinsumGraph) -> Result<usize>
Build patch embedding einsum graph
Converts image patches to token embeddings
§Graph Inputs
- Tensor 0: Input image tensor
[batch, in_channels, height, width]or patches[batch, num_patches, patch_dim] - Tensor 1: Patch embedding weights
[patch_dim, d_model]
§Graph Output
- Embedded patches
[batch, num_patches, d_model]
Sourcepub fn config(&self) -> &PatchEmbeddingConfig
pub fn config(&self) -> &PatchEmbeddingConfig
Get configuration
Auto Trait Implementations§
impl Freeze for PatchEmbedding
impl RefUnwindSafe for PatchEmbedding
impl Send for PatchEmbedding
impl Sync for PatchEmbedding
impl Unpin for PatchEmbedding
impl UnwindSafe for PatchEmbedding
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