pub struct LearnablePosEmbed {
pub table: Vec<f32>,
pub n_positions: usize,
pub embed_dim: usize,
}Expand description
Learnable position embedding table: [n_positions, embed_dim].
Row i is the position embedding for the i-th token (index 0 is
conventionally the CLS token position).
Fields§
§table: Vec<f32>Flat [n_positions × embed_dim] parameter table.
n_positions: usizeNumber of positions (including CLS if present).
embed_dim: usizeEmbedding dimension.
Implementations§
Source§impl LearnablePosEmbed
impl LearnablePosEmbed
Sourcepub fn new(
n_positions: usize,
embed_dim: usize,
rng: &mut LcgRng,
) -> VisionResult<Self>
pub fn new( n_positions: usize, embed_dim: usize, rng: &mut LcgRng, ) -> VisionResult<Self>
Create a learnable position embedding with small Gaussian init.
Sourcepub fn position_embedding(&self, i: usize) -> VisionResult<&[f32]>
pub fn position_embedding(&self, i: usize) -> VisionResult<&[f32]>
Return the embedding for position i as a slice of length embed_dim.
Trait Implementations§
Source§impl Clone for LearnablePosEmbed
impl Clone for LearnablePosEmbed
Source§fn clone(&self) -> LearnablePosEmbed
fn clone(&self) -> LearnablePosEmbed
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 LearnablePosEmbed
impl RefUnwindSafe for LearnablePosEmbed
impl Send for LearnablePosEmbed
impl Sync for LearnablePosEmbed
impl Unpin for LearnablePosEmbed
impl UnsafeUnpin for LearnablePosEmbed
impl UnwindSafe for LearnablePosEmbed
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