gammagl.models.DeepWalkModel

class DeepWalkModel(edge_index, edge_weight, embedding_dim, walk_length, num_walks=10, window_size=5, num_negatives=1, num_nodes=None, name=None)[source]

The DeepWalk model from the “DeepWalk: Online Learning of Social Representations” paper where random walks of length walk_length are sampled in a given graph, and node embeddings are learned via negative sampling optimization.

Parameters:
  • edge_index (Iterable) – The edge indices.

  • edge_weight (Iterable) – The edge weight.

  • embedding_dim (int) – The size of each embedding vector.

  • walk_length (int) – The walk length.

  • num_walks (int, optional) – The number of walks to sample for each node.

  • window_size (int, optional) – The actual context size which is considered for positive samples. This parameter increases the effective sampling rate by reusing samples across different source nodes.

  • num_negatives (int, optional) – The number of negative samples to use for each positive sample.

  • num_nodes (int, optional) – The number of nodes.

  • name (str, optional) – model name.

forward(edge_index)[source]

Define 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.

pos_sample()[source]
neg_sample()[source]
loss(pos_rw, neg_rw)[source]
campute()[source]