scvi.nn.Embedding#
- class scvi.nn.Embedding(num_embeddings, embedding_dim, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False, _weight=None, _freeze=False, device=None, dtype=None)[source]#
Bases:
EmbeddingEmbedding layer with utility methods for extending.
Attributes table#
Methods table#
Attributes#
Methods#
- classmethod Embedding.extend(embedding, init, freeze_prev=True)[source]#
Factory class method for extending an existing
Embedding.Initializes new embeddings with random values or copies from the original embedding.
- Parameters:
- embedding
Embedding Embedding layer to extend. Not modified in-place as a new instance is returned.
- init
int|list[int] If an
int, specifies the number of new random embeddings to initialize withnormal_(). If alist[int], initializeslen(init)new embeddings with the values of the given indices in the original embedding.- freeze_prev
bool(default:True) If
True, gradients for the original embeddings are set to zero.
- embedding
- Return type:
- Returns:
New
Embeddinginstance withnum_embeddingsincreased by the specifiedinitand with gradients frozen for the firstembedding.num_embeddingsentries iffreeze_previsTrue.