pyg_spectral.utils
- get_laplacian(edge_index: Tensor | SparseTensor, edge_weight: Tensor | None = None, normalization: bool | None = None, diag: float = 1.0, dtype: dtype | None = None, num_nodes: int | None = None) Tuple[Tensor, Tensor] | SparseTensor [source]
Computes the graph Laplacian of the graph given by
edge_index
and optionaledge_weight
. Remove the normalization of graph adjacency matrix intorch_geometric.utils.get_laplacian()
.- Parameters:
edge_index (
Tensor
|SparseTensor
) – The edge indices.edge_weight (
Tensor
|None
, default:None
) – One-dimensional edge weights.normalization (
bool
|None
, default:None
) –The normalization scheme for the graph Laplacian:
1.
False
: No normalization \(\mathbf{L} = \mathbf{D} - \mathbf{A}\)2.
"True"
: Normalization already applied \(\mathbf{L} = diag * \mathbf{I} - \mathbf{A}\)diag (
float
, default:1.0
) – Weight of identity when normalization=True.dtype (
dtype
|None
, default:None
) – The desired data type of returned tensor in caseedge_weight=None
.num_nodes (
int
|None
, default:None
) – The number of nodes, i.e.max_val + 1
ofedge_index
.
- dropout_edge(edge_index: Tensor, p: float = 0.5, force_undirected: bool = False, training: bool = True) Tuple[Tensor, Tensor] [source]
Random inplace edge dropout for the adjacency matrix
edge_index
with probabilityp
using samples from a Bernoulli distribution. Expandtorch_geometric.utils.dropout_edge()
with type support.- Parameters:
- Returns:
edge_index, edge_mask (
LongTensor, BoolTensor
) – The edge indices and the edge mask.