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:
EmbeddingEXPERIMENTALEmbedding layer with utility methods for extending.
Attributes table#
Methods table#
Attributes#
- Embedding.num_embeddings: int#
- Embedding.embedding_dim: int#
- Embedding.padding_idx: int | None#
- Embedding.max_norm: float | None#
- Embedding.norm_type: float#
- Embedding.scale_grad_by_freq: bool#
- Embedding.weight: Tensor#
- Embedding.freeze: bool#
- Embedding.sparse: bool#
- Embedding.training: bool#
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 anint, 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)) – IfTrue, gradients for the original embeddings are set to zero.
- Return type:
- Returns:
New
Embeddinginstance withnum_embeddingsincreased by the specifiedinitand with gradients frozen for the firstembedding.num_embeddingsentries iffreeze_previsTrue.