Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct { nn.Module Size int Dim int Weights []*nn.Param // contains filtered or unexported fields }
Model implements a simple lookup table that stores fixed-size embeddings for a predefined dictionary. It is commonly used to store and retrieve word embeddings using their corresponding indices.
func (*Model) CountEmbedWithGrad ¶
func (*Model) Encode ¶
Encode returns the embedding values associated with the input indices. It returns an error if one of the input elements is out of range.
func (*Model) MustEncode ¶
MustEncode returns the embedding values associated with the input indices.
func (*Model) TraverseParams ¶
TraverseParams allows embeddings with gradients to be traversed for optimization.
type Shared ¶
type Shared struct {
}Shared wraps Model, overriding binary marshaling methods in order to produce (and expect) empty data. This is useful e.g. to share embeddings between encoder and decoder models.
func (Shared) MarshalBinary ¶
MarshalBinary satisfies encoding.BinaryMarshaler interface. It always produces empty data (nil) and no error.
func (Shared) UnmarshalBinary ¶
UnmarshalBinary satisfies encoding.BinaryUnmarshaler interface. It only accepts empty data (nil or zero-length slice), producing no side effects at all. If data is not blank, it returns an error.