MCPcopy Create free account
hub / github.com/PythonOT/POT / TWPooling

Class TWPooling

ot/gnn/_layers.py:182–293  ·  view source on GitHub ↗

r""" Template Wasserstein (TW) layer, also known as OT-GNN layer. This layer is a pooling layer for graph neural networks. Computes the Wasserstein distances between the features of the graph features and a set of templates. .. math:: TW_{\overline{\mathcal{G}}}(C,F,h)=[W(F,

Source from the content-addressed store, hash-verified

180
181
182class TWPooling(nn.Module):
183 r"""
184 Template Wasserstein (TW) layer, also known as OT-GNN layer. This layer is a pooling layer for graph neural networks.
185 Computes the Wasserstein distances between the features of the graph features and a set of templates.
186
187 .. math::
188 TW_{\overline{\mathcal{G}}}(C,F,h)=[W(F,h,\overline{F}_k,\overline{h}_k)]_{k=1}^{K}
189
190 where :
191
192 - :math:`\mathcal{G}=\{(\overline{F}_k,\overline{h}_k) \}_{k \in \{1,...,K \}} \}` is the set of :math:`K` templates characterized by their feature matrices :math:`\overline{F}_k` and their node weights :math:`\overline{h}_k`.
193 - :math:`F` and :math:`h` are respectively the feature matrix and the node weights of the graph.
194
195 Parameters
196 ----------
197 n_features : int
198 Feature dimension of the nodes.
199 n_tplt : int
200 Number of graph templates.
201 n_tplt_nodes : int
202 Number of nodes in each template.
203 train_node_weights : bool, optional
204 If True, the templates node weights are learned.
205 Else, they are uniform.
206 feature_init_mean: float, optional
207 Mean of the random normal law to initialize the template features.
208 feature_init_std: float, optional
209 Standard deviation of the random normal law to initialize the template features.
210
211 References
212 ----------
213 .. [54] Bécigneul, G., Ganea, O. E., Chen, B., Barzilay, R., & Jaakkola, T. S. (2020). [Optimal transport graph neural networks]
214
215 """
216
217 def __init__(
218 self,
219 n_features,
220 n_tplt=2,
221 n_tplt_nodes=2,
222 train_node_weights=True,
223 feature_init_mean=0.0,
224 feature_init_std=1.0,
225 ):
226 r"""
227 Template Wasserstein (TW) layer, also known as OT-GNN layer. This layer is a pooling layer for graph neural networks.
228 Computes the Wasserstein distances between the features of the graph features and a set of templates.
229
230 .. math::
231 TW_{\overline{\mathcal{G}}}(C,F,h)=[W(F,h,\overline{F}_k,\overline{h}_k)]_{k=1}^{K}
232
233 where :
234
235 - :math:`\mathcal{G}=\{(\overline{F}_k,\overline{h}_k) \}_{k \in \llbracket 1;K \rrbracket }` is the set of :math:`K` templates characterized by their feature matrices :math:`\overline{F}_k` and their node weights :math:`\overline{h}_k`.
236 - :math:`F` and :math:`h` are respectively the feature matrix and the node weights of the graph.
237
238 Parameters
239 ----------

Callers 2

test_TW_variantsFunction · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 2

test_TW_variantsFunction · 0.72
__init__Method · 0.72