Combines one-hot encoding and linear projection in a single efficient operation to convert categorical indices to embeddings.
Examples
if (FALSE) { # \dontrun{
encoder <- one_hot_and_linear(num_classes = 10L, embed_dim = 32L)
indices <- torch_randint(1L, 11L, c(2L, 20L)) # [batch, seq_len]
embeddings <- encoder(indices) # [batch, seq_len, embed_dim]
} # }