pub struct TokenEmbedding {
pub vocab_size: usize,
pub embed_dim: usize,
pub weight: WeightTensor,
}Expand description
Token embedding table: maps token ids to dense vectors.
Weight shape: [vocab_size × embed_dim].
Output shape: [seq_len × embed_dim].
Fields§
§vocab_size: usizeVocabulary size.
embed_dim: usizeEmbedding dimension.
weight: WeightTensorWeight table: [vocab_size × embed_dim], row-major.
Implementations§
Source§impl TokenEmbedding
impl TokenEmbedding
Sourcepub fn new(vocab_size: usize, embed_dim: usize) -> LmResult<Self>
pub fn new(vocab_size: usize, embed_dim: usize) -> LmResult<Self>
Construct with zero-initialised weights.
Sourcepub fn from_weight(weight: WeightTensor) -> LmResult<Self>
pub fn from_weight(weight: WeightTensor) -> LmResult<Self>
Construct from an existing weight tensor.
Trait Implementations§
Source§impl Clone for TokenEmbedding
impl Clone for TokenEmbedding
Source§fn clone(&self) -> TokenEmbedding
fn clone(&self) -> TokenEmbedding
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 TokenEmbedding
impl RefUnwindSafe for TokenEmbedding
impl Send for TokenEmbedding
impl Sync for TokenEmbedding
impl Unpin for TokenEmbedding
impl UnsafeUnpin for TokenEmbedding
impl UnwindSafe for TokenEmbedding
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