pub struct PatchEmbedding {
pub projection_w: Tensor,
pub projection_b: Tensor,
pub image_size: usize,
pub patch_size: usize,
pub in_channels: usize,
pub embed_dim: usize,
pub num_patches: usize,
}Expand description
Patch embedding layer for Vision Transformer.
Splits an NHWC image into non-overlapping patches and projects each patch to an embedding vector via a linear projection (equivalent to Conv2d with kernel_size=patch_size, stride=patch_size).
Input: [batch, H, W, C] (NHWC)
Output: [batch, num_patches, embed_dim]
Fields§
§projection_w: TensorLinear projection weight: [patch_size * patch_size * in_channels, embed_dim]
projection_b: TensorLinear projection bias: [embed_dim]
image_size: usize§patch_size: usize§in_channels: usize§embed_dim: usize§num_patches: usizeImplementations§
Auto Trait Implementations§
impl Freeze for PatchEmbedding
impl RefUnwindSafe for PatchEmbedding
impl Send for PatchEmbedding
impl Sync for PatchEmbedding
impl Unpin for PatchEmbedding
impl UnsafeUnpin 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more