Layers and functions for optimal transport in Graph Neural Networks.
Warning
Note that by default the module is not imported in ot
. In order to use it you need to explicitly import ot.gnn
. This module is PyTorch Geometric dependent. The layers are compatible with their API.
Computes the FGW distances between a graph and templates.
G_edges (torch.Tensor, shape (n_edges, 2)) – Edge indices of the graph in the Pytorch Geometric format.
tplt_adjacencies (list of torch.Tensor, shape (n_templates, n_template_nodes, n_templates_nodes)) – List of the adjacency matrices of the templates.
G_features (torch.Tensor, shape (n_nodes, n_features)) – Graph node features.
tplt_features (list of torch.Tensor, shape (n_templates, n_template_nodes, n_features)) – List of the node features of the templates.
weights (torch.Tensor, shape (n_templates, n_template_nodes)) – Weights on the nodes of the templates.
alpha (float, optional) – Trade-off parameter (0 < alpha < 1). Weights features (alpha=0) and structure (alpha=1).
multi_alpha (bool, optional) – If True, the alpha parameter is a vector of size n_templates.
batch (torch.Tensor, optional) – Batch vector which assigns each node to its graph.
distances – Vector of fused Gromov-Wasserstein distances between the graph and the templates.
torch.Tensor, shape (n_templates) if batch=None, else shape (n_graphs, n_templates).
Computes the fused Gromov-Wasserstein distances between the graph and a set of templates.
\[TFGW_{ \overline{ \mathcal{G} }, \alpha }(C,F,h)=[ FGW_{\alpha}(C,F,h,\overline{C}_k,\overline{F}_k,\overline{h}_k)]_{k=1}^{K}\]
where :
\(\mathcal{G}=\{(\overline{C}_k,\overline{F}_k,\overline{h}_k) \}_{k \in \{1,...,K \}} \}\) is the set of \(K\) templates characterized by their adjacency matrices \(\overline{C}_k\), their feature matrices \(\overline{F}_k\) and their node weights \(\overline{h}_k\).
\(C\), \(F\) and \(h\) are respectively the adjacency matrix, the feature matrix and the node weights of the graph.
\(\alpha\) is the trade-off parameter between features and structure for the Fused Gromov-Wasserstein distance.
n_features (int) – Feature dimension of the nodes.
n_tplt (int) – Number of graph templates.
n_tplt_nodes (int) – Number of nodes in each template.
alpha (float, optional) – FGW trade-off parameter (0 < alpha < 1). If None alpha is trained, else it is fixed at the given value. Weights features (alpha=0) and structure (alpha=1).
train_node_weights (bool, optional) – If True, the templates node weights are learned. Else, they are uniform.
multi_alpha (bool, optional) – If True, the alpha parameter is a vector of size n_tplt.
feature_init_mean (float, optional) – Mean of the random normal law to initialize the template features.
feature_init_std (float, optional) – Standard deviation of the random normal law to initialize the template features.
References
x (torch.Tensor) – Node features.
edge_index (torch.Tensor) – Edge indices.
batch (torch.Tensor, optional) – Batch vector which assigns each node to its graph.
Computes the Wasserstein distances between the features of the graph features and a set of templates.
\[TW_{\overline{\mathcal{G}}}(C,F,h)=[W(F,h,\overline{F}_k,\overline{h}_k)]_{k=1}^{K}\]
where :
\(\mathcal{G}=\{(\overline{F}_k,\overline{h}_k) \}_{k \in \{1,...,K \}} \}\) is the set of \(K\) templates characterized by their feature matrices \(\overline{F}_k\) and their node weights \(\overline{h}_k\).
\(F\) and \(h\) are respectively the feature matrix and the node weights of the graph.
n_features (int) – Feature dimension of the nodes.
n_tplt (int) – Number of graph templates.
n_tplt_nodes (int) – Number of nodes in each template.
train_node_weights (bool, optional) – If True, the templates node weights are learned. Else, they are uniform.
feature_init_mean (float, optional) – Mean of the random normal law to initialize the template features.
feature_init_std (float, optional) – Standard deviation of the random normal law to initialize the template features.
References
x (torch.Tensor) – Node features.
edge_index (torch.Tensor) – Edge indices.
batch (torch.Tensor, optional) – Batch vector which assigns each node to its graph.
Computes the Wasserstein distances between a graph and graph templates.
G_features (torch.Tensor, shape (n_nodes, n_features)) – Node features of the graph.
tplt_features (list of torch.Tensor, shape (n_templates, n_template_nodes, n_features)) – List of the node features of the templates.
weights (torch.Tensor, shape (n_templates, n_template_nodes)) – Weights on the nodes of the templates.
batch (torch.Tensor, optional) – Batch vector which assigns each node to its graph.
distances – Vector of Wasserstein distances between the graph and the templates.
torch.Tensor, shape (n_templates) if batch=None, else shape (n_graphs, n_templates)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4