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.
dropout_adj
(edge_index: torch.Tensor, edge_weight: Optional[torch.Tensor] = None, drop_rate: float = 0.5, renorm: bool = True)[source]¶
-
cogdl.utils.utils.
edge_softmax
(indices, values, shape)[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.
mul_edge_softmax
(indices, values, shape)[source]¶ - Args:
- indices: Tensor, shape=(2, E) values: Tensor, shape=(E, d) shape: tuple(int, int)
- Returns:
- Softmax values of multi-dimension edge values for nodes
-
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
(edge_index, edge_weight, x, num_nodes=None)[source]¶ - Args:
- edge_index : Tensor, shape=(2, E) edge_weight : Tensor, shape=(E,) x : Tensor, shape=(N, ) num_nodes : Optional[int]
-
cogdl.utils.utils.
spmm_scatter
(indices, 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.