pub struct SparseEmbedding { /* private fields */ }Expand description
Sparse embedding layer
Implementations§
Source§impl SparseEmbedding
impl SparseEmbedding
Sourcepub fn new(
vocab_size: usize,
embedding_dim: usize,
sparsity: f32,
) -> TorshResult<Self>
pub fn new( vocab_size: usize, embedding_dim: usize, sparsity: f32, ) -> TorshResult<Self>
Create a new sparse embedding layer
Sourcepub fn forward(&self, indices: &[usize]) -> TorshResult<Tensor>
pub fn forward(&self, indices: &[usize]) -> TorshResult<Tensor>
Forward pass - lookup embeddings for given indices
Sourcepub fn get_embedding(&self, index: usize) -> TorshResult<Tensor>
pub fn get_embedding(&self, index: usize) -> TorshResult<Tensor>
Get embedding for a single index
Sourcepub fn num_parameters(&self) -> usize
pub fn num_parameters(&self) -> usize
Get number of parameters
Auto Trait Implementations§
impl !Freeze for SparseEmbedding
impl RefUnwindSafe for SparseEmbedding
impl Send for SparseEmbedding
impl Sync for SparseEmbedding
impl Unpin for SparseEmbedding
impl UnsafeUnpin for SparseEmbedding
impl UnwindSafe for SparseEmbedding
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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