TorchLean API

NN.Spec.Module.Embedding

Embedding #

Module wrappers for spec-layer embeddings.

We intentionally expose the one-hot embedding variant here (purely numeric, no integer indices).

Why one-hot in the spec layer:

In PyTorch terms: the usual API is nn.Embedding(vocab, embed_dim) on integer indices. This file packages the equivalent "one_hot then matmul" semantics.

def Spec.EmbeddingOneHotModuleSpec {α : Type} [Context α] {vocab embedDim seqLen : } (emb : EmbeddingSpec vocab embedDim α) :

One-hot embedding wrapper: (seqLen,vocab)(seqLen,embedDim).

Instances For