r""" Template Fused Gromov-Wasserstein (TFGW) layer. This layer is a pooling layer for graph neural networks. Computes the fused Gromov-Wasserstein distances between the graph and a set of templates. .. math:: TFGW_{ \overline{ \mathcal{G} }, \alpha }(C,F,h)=[ FGW_{\alpha}(
| 18 | |
| 19 | |
| 20 | class TFGWPooling(nn.Module): |
| 21 | r""" |
| 22 | Template Fused Gromov-Wasserstein (TFGW) layer. This layer is a pooling layer for graph neural networks. |
| 23 | Computes the fused Gromov-Wasserstein distances between the graph and a set of templates. |
| 24 | |
| 25 | |
| 26 | .. math:: |
| 27 | 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} |
| 28 | |
| 29 | where : |
| 30 | |
| 31 | - :math:`\mathcal{G}=\{(\overline{C}_k,\overline{F}_k,\overline{h}_k) \}_{k \in \{1,...,K \}} \}` is the set of :math:`K` templates characterized by their adjacency matrices :math:`\overline{C}_k`, their feature matrices :math:`\overline{F}_k` and their node weights :math:`\overline{h}_k`. |
| 32 | - :math:`C`, :math:`F` and :math:`h` are respectively the adjacency matrix, the feature matrix and the node weights of the graph. |
| 33 | - :math:`\alpha` is the trade-off parameter between features and structure for the Fused Gromov-Wasserstein distance. |
| 34 | |
| 35 | |
| 36 | Parameters |
| 37 | ---------- |
| 38 | n_features : int |
| 39 | Feature dimension of the nodes. |
| 40 | n_tplt : int |
| 41 | Number of graph templates. |
| 42 | n_tplt_nodes : int |
| 43 | Number of nodes in each template. |
| 44 | alpha : float, optional |
| 45 | FGW trade-off parameter (0 < alpha < 1). If None alpha is trained, else it is fixed at the given value. |
| 46 | Weights features (alpha=0) and structure (alpha=1). |
| 47 | train_node_weights : bool, optional |
| 48 | If True, the templates node weights are learned. |
| 49 | Else, they are uniform. |
| 50 | multi_alpha: bool, optional |
| 51 | If True, the alpha parameter is a vector of size n_tplt. |
| 52 | feature_init_mean: float, optional |
| 53 | Mean of the random normal law to initialize the template features. |
| 54 | feature_init_std: float, optional |
| 55 | Standard deviation of the random normal law to initialize the template features. |
| 56 | |
| 57 | |
| 58 | |
| 59 | References |
| 60 | ---------- |
| 61 | .. [53] Cédric Vincent-Cuaz, Rémi Flamary, Marco Corneli, Titouan Vayer, Nicolas Courty. |
| 62 | "Template based graph neural network with optimal transport distances" |
| 63 | """ |
| 64 | |
| 65 | def __init__( |
| 66 | self, |
| 67 | n_features, |
| 68 | n_tplt=2, |
| 69 | n_tplt_nodes=2, |
| 70 | alpha=None, |
| 71 | train_node_weights=True, |
| 72 | multi_alpha=False, |
| 73 | feature_init_mean=0.0, |
| 74 | feature_init_std=1.0, |
| 75 | ): |
| 76 | r""" |
| 77 | Template Fused Gromov-Wasserstein (TFGW) layer. This layer is a pooling layer for graph neural networks. |
no outgoing calls