View source on GitHub |
A template for edge convolutions.
tfg.geometry.convolution.graph_convolution.edge_convolution_template(
data: type_alias.TensorLike,
neighbors: tf.sparse.SparseTensor,
sizes: type_alias.TensorLike,
edge_function: Callable[[type_alias.TensorLike, type_alias.TensorLike], type_alias.TensorLike],
reduction: str,
edge_function_kwargs: Dict[str, Any],
name: str = 'graph_convolution_edge_convolution_template'
) -> tf.Tensor
This function implements a general edge convolution for graphs of the form \(y_i = \sum_{j \in \mathcal{N}(i)} w_{ij} f(x_i, x_j)\), where \(\mathcal{N}(i)\) is the set of vertices in the neighborhood of vertex \(i\), \(x_i \in \mathbb{R}^C\) are the features at vertex \(i\), \(w_{ij} \in \mathbb{R}\) is the weight for the edge between vertex \(i\) and vertex \(j\), and finally \(f(x_i, x_j): \mathbb{R}^{C} \times \mathbb{R}^{C} \to \mathbb{R}^{D}\) is a user-supplied function.
This template also implements the same general edge convolution described above with a max-reduction instead of a weighted sum.
An example of how this template can be used is for Laplacian smoothing,
which is defined as
\(y_i = \frac{1}{|\mathcal{N(i)}|} \sum_{j \in \mathcal{N(i)} } x_j\).
edge_convolution_template
can be used to perform Laplacian smoothing by
setting
\(w_{ij} = \frac{1}{|\mathcal{N(i)}|}\), edge_function=lambda x, y: y
,
and reduction='weighted'
.
The shorthands used below are
V
: The number of vertices.
C
: The number of channels in the input data.
Note | |
---|---|
In the following, A1 to An are optional batch dimensions. |
Returns | |
---|---|
Tensor with shape [A1, ..., An, V, D] .
|
Raises | |
---|---|
TypeError
|
if the input types are invalid. |
ValueError
|
if the input dimensions are invalid. |