sketchgraphs_models.graph.model.message_passing.DenseSparsePreEmbedding

class sketchgraphs_models.graph.model.message_passing.DenseSparsePreEmbedding(target_type, feature_embeddings, fixed_embedding_cardinality, fixed_embedding_dim, sparse_embedding_dim=None, embedding_dim=None)

This is a generic pre-embedding module which combines dense and sparse pre-embeddings.

__init__(target_type, feature_embeddings, fixed_embedding_cardinality, fixed_embedding_dim, sparse_embedding_dim=None, embedding_dim=None)

Initializes a new DenseSparsePreEmbedding module.

Parameters
  • target_type (enum) – The underlying enumeration indicating target types

  • feature_embeddings (dict of modules) – A dictionary of embeddings for each of the sparse feature types.

  • fixed_embedding_cardinality (int) – The number of classes in the fixed (dense) embedding layer.

  • fixed_embedding_dim (int) – The dimension of the embedding for the fixed layer.

  • sparse_embedding_dim (int, optional) – The dimension of the sparse embeddings. If None, assumed to be the same as the dense embedding.

  • embedding_dim (int, optional) – The outpu dimension of the embedding. If None, assumed to be the same as the dense embedding.

forward(fixed_features, sparse_features)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.