utils¶
-
cogdl.utils.utils.
add_remaining_self_loops
(edge_index, edge_weight=None, fill_value=1, num_nodes=None)[source]¶
-
cogdl.utils.utils.
add_self_loops
(edge_index, edge_weight=None, fill_value=1, num_nodes=None)[source]¶
-
cogdl.utils.utils.
alias_draw
(J, q)[source]¶ Draw sample from a non-uniform discrete distribution using alias sampling.
-
cogdl.utils.utils.
alias_setup
(probs)[source]¶ Compute utility lists for non-uniform sampling from discrete distributions. Refer to https://hips.seas.harvard.edu/blog/2013/03/03/the-alias-method-efficient-sampling-with-many-discrete-outcomes/ for details
-
cogdl.utils.utils.
download_url
(url, folder, name=None, log=True)[source]¶ Downloads the content of an URL to a specific folder.
-
cogdl.utils.utils.
edge_softmax
(graph, edge_val)[source]¶ - Args:
- indices: Tensor, shape=(2, E) values: Tensor, shape=(N,) shape: tuple(int, int)
- Returns:
- Softmax values of edge values for nodes
-
cogdl.utils.utils.
mh_spmm
(graph, attention, h)[source]¶ - Multi-head spmm
- Args:
- graph: Graph attention: torch.Tensor([E, H]) h: torch.Tensor([N, d])
- Returns:
- torch.Tensor([N, H, d])
-
cogdl.utils.utils.
mul_edge_softmax
(graph, edge_val)[source]¶ - Returns:
- Softmax values of multi-dimension edge values. shape: [E, H]
-
cogdl.utils.utils.
negative_edge_sampling
(edge_index: torch.Tensor, num_nodes: Optional[int] = None, num_neg_samples: Optional[int] = None, undirected: bool = False)[source]¶
-
cogdl.utils.utils.
spmm_scatter
(row, col, values, b)[source]¶ - Args:
- indices : Tensor, shape=(2, E) values : Tensor, shape=(E,) b : Tensor, shape=(N, )
-
cogdl.utils.utils.
to_undirected
(edge_index, num_nodes=None)[source]¶ Converts the graph given by
edge_index
to an undirected graph, so that \((j,i) \in \mathcal{E}\) for every edge \((i,j) \in \mathcal{E}\).- Args:
edge_index (LongTensor): The edge indices. num_nodes (int, optional): The number of nodes, i.e.
Return type: LongTensor
-
cogdl.utils.utils.
untar
(path, fname, deleteTar=True)[source]¶ Unpacks the given archive file to the same directory, then (by default) deletes the archive file.