Skip to content

Commit 66f2e1b

Browse files
aferludintensorflower-gardener
authored andcommitted
Refresh api_docs at commit
PiperOrigin-RevId: 549650225
1 parent 035b569 commit 66f2e1b

File tree

114 files changed

+3012
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3012
-575
lines changed

tensorflow_gnn/docs/api_docs/python/models/gat_v2.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ GraphUpdate layer with a Graph Attention Network V2 (GATv2).
3737

3838
[`GATv2MPNNGraphUpdate(...)`](./gat_v2/GATv2MPNNGraphUpdate.md): Returns a
3939
GraphUpdate layer for message passing with GATv2 pooling.
40+
41+
[`graph_update_from_config_dict(...)`](./gat_v2/graph_update_from_config_dict.md):
42+
Returns a GATv2MPNNGraphUpdate initialized from `cfg`.
43+
44+
[`graph_update_get_config_dict(...)`](./gat_v2/graph_update_get_config_dict.md):
45+
Returns ConfigDict for graph_update_from_config_dict() with defaults.

tensorflow_gnn/docs/api_docs/python/models/gat_v2/GATv2Conv.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
88
<td>
9-
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L22-L323">
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L22-L331">
1010
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
1111
View source on GitHub
1212
</a>
@@ -29,8 +29,8 @@ The multi-head attention from Graph Attention Networks v2 (GATv2).
2929
attention_activation: Union[str, Callable[..., Any]] = &#x27;leaky_relu&#x27;,
3030
heads_merge_type: str = &#x27;concat&#x27;,
3131
activation: Union[str, Callable[..., Any]] = &#x27;relu&#x27;,
32-
kernel_initializer: Union[None, str, tf.keras.initializers.Initializer] = None,
33-
kernel_regularizer: Union[None, str, tf.keras.regularizers.Regularizer] = None,
32+
kernel_initializer: Any = None,
33+
kernel_regularizer: Any = None,
3434
**kwargs
3535
)
3636
</code></pre>
@@ -140,7 +140,7 @@ from this input.)
140140
<td>
141141
Can be set to override `tfgnn.HIDDEN_STATE` for use as
142142
the input feature from sender nodes to attention.
143-
IMPORANT: Must be set to `None` for use with `receiver_tag=tfgnn.CONTEXT`
143+
IMPORTANT: Must be set to `None` for use with `receiver_tag=tfgnn.CONTEXT`
144144
on an edge set, or for pooling from edges without sender node states.
145145
</td>
146146
</tr><tr>
@@ -179,7 +179,7 @@ is dropped out.)
179179
The nonlinearity used on the transformed inputs
180180
before multiplying with the trained weights of the attention layer.
181181
This can be specified as a Keras layer, a tf.keras.activations.*
182-
function, or a string understood by tf.keras.layers.Activation().
182+
function, or a string understood by `tf.keras.layers.Activation()`.
183183
Defaults to "leaky_relu", which in turn defaults to a negative slope
184184
of `alpha=0.2`.
185185
</td>
@@ -206,8 +206,10 @@ specified in the same ways as attention_activation.
206206
`kernel_initializer`<a id="kernel_initializer"></a>
207207
</td>
208208
<td>
209-
Can be set to a `kerner_initializer` as understood
209+
Can be set to a `kernel_initializer` as understood
210210
by `tf.keras.layers.Dense` etc.
211+
An `Initializer` object gets cloned before use to ensure a fresh seed,
212+
if not set explicitly. For more, see `tfgnn.keras.clone_initializer()`.
211213
</td>
212214
</tr><tr>
213215
<td>
@@ -310,7 +312,7 @@ If `False`, all calls to convolve() will get `sender_node_input=None`.
310312

311313
<h3 id="convolve"><code>convolve</code></h3>
312314

313-
<a target="_blank" class="external" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L242-L301">View
315+
<a target="_blank" class="external" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L250-L309">View
314316
source</a>
315317

316318
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">

tensorflow_gnn/docs/api_docs/python/models/gat_v2/GATv2EdgePool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
88
<td>
9-
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L361-L412">
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L369-L420">
1010
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
1111
View source on GitHub
1212
</a>

tensorflow_gnn/docs/api_docs/python/models/gat_v2/GATv2HomGraphUpdate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
88
<td>
9-
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L416-L470">
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L424-L476">
1010
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
1111
View source on GitHub
1212
</a>

tensorflow_gnn/docs/api_docs/python/models/gat_v2/GATv2MPNNGraphUpdate.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
88
<td>
9-
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L487-L581">
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/layers.py#L493-L589">
1010
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
1111
View source on GitHub
1212
</a>
@@ -31,7 +31,7 @@ Returns a GraphUpdate layer for message passing with GATv2 pooling.
3131
attention_activation: Union[str, Callable[..., Any]] = &#x27;leaky_relu&#x27;,
3232
conv_activation: Union[str, Callable[..., Any]] = &#x27;relu&#x27;,
3333
activation: Union[str, Callable[..., Any]] = &#x27;relu&#x27;,
34-
kernel_initializer: Union[None, str, tf.keras.initializers.Initializer] = &#x27;glorot_uniform&#x27;
34+
kernel_initializer: Any = &#x27;glorot_uniform&#x27;
3535
) -> tf.keras.layers.Layer
3636
</code></pre>
3737

@@ -136,7 +136,7 @@ The dropout rate applied to the resulting node states.
136136
The nonlinearity used on the transformed inputs
137137
before multiplying with the trained weights of the attention layer.
138138
This can be specified as a Keras layer, a tf.keras.activations.*
139-
function, or a string understood by tf.keras.layers.Activation().
139+
function, or a string understood by `tf.keras.layers.Activation()`.
140140
Defaults to "leaky_relu", which in turn defaults to a negative slope
141141
of `alpha=0.2`.
142142
</td>
@@ -161,7 +161,7 @@ this graph update.
161161
`kernel_initializer`<a id="kernel_initializer"></a>
162162
</td>
163163
<td>
164-
Can be set to a `kerner_initializer` as understood
164+
Can be set to a `kernel_initializer` as understood
165165
by `tf.keras.layers.Dense` etc.
166166
</td>
167167
</tr>

tensorflow_gnn/docs/api_docs/python/models/gat_v2/all_symbols.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
* <a href="../gat_v2/GATv2EdgePool.md"><code>gat_v2.GATv2EdgePool</code></a>
1010
* <a href="../gat_v2/GATv2HomGraphUpdate.md"><code>gat_v2.GATv2HomGraphUpdate</code></a>
1111
* <a href="../gat_v2/GATv2MPNNGraphUpdate.md"><code>gat_v2.GATv2MPNNGraphUpdate</code></a>
12+
* <a href="../gat_v2/graph_update_from_config_dict.md"><code>gat_v2.graph_update_from_config_dict</code></a>
13+
* <a href="../gat_v2/graph_update_get_config_dict.md"><code>gat_v2.graph_update_get_config_dict</code></a>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# gat_v2.graph_update_from_config_dict
2+
3+
[TOC]
4+
5+
<!-- Insert buttons and diff -->
6+
7+
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
8+
<td>
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/config_dict.py#L42-L62">
10+
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
11+
View source on GitHub
12+
</a>
13+
</td>
14+
</table>
15+
16+
Returns a GATv2MPNNGraphUpdate initialized from `cfg`.
17+
18+
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
19+
<code>gat_v2.graph_update_from_config_dict(
20+
cfg: config_dict.ConfigDict
21+
) -> tf.keras.layers.Layer
22+
</code></pre>
23+
24+
<!-- Placeholder for "Used in" -->
25+
<!-- Tabular view -->
26+
27+
<table class="responsive fixed orange">
28+
<colgroup><col width="214px"><col></colgroup>
29+
<tr><th colspan="2"><h2 class="add-link">Args</h2></th></tr>
30+
31+
<tr>
32+
<td>
33+
`cfg`<a id="cfg"></a>
34+
</td>
35+
<td>
36+
A `ConfigDict` with the fields defined by
37+
`graph_update_get_config_dict()`. All fields with non-`None` values are
38+
used as keyword arguments for initializing and returning a
39+
`GATv2MPNNGraphUpdate` object. For the required arguments of
40+
`GATv2MPNNGraphUpdate.__init__`, users must set a value in
41+
`cfg` before passing it here.
42+
</td>
43+
</tr>
44+
</table>
45+
46+
<!-- Tabular view -->
47+
48+
<table class="responsive fixed orange">
49+
<colgroup><col width="214px"><col></colgroup>
50+
<tr><th colspan="2"><h2 class="add-link">Returns</h2></th></tr>
51+
<tr class="alt">
52+
<td colspan="2">
53+
A new `GATv2MPNNGraphUpdate` object.
54+
</td>
55+
</tr>
56+
57+
</table>
58+
59+
<!-- Tabular view -->
60+
61+
<table class="responsive fixed orange">
62+
<colgroup><col width="214px"><col></colgroup>
63+
<tr><th colspan="2"><h2 class="add-link">Raises</h2></th></tr>
64+
65+
<tr>
66+
<td>
67+
`TypeError`<a id="TypeError"></a>
68+
</td>
69+
<td>
70+
if `cfg` fails to supply a required argument for
71+
`GATv2MPNNGraphUpdate.__init__`.
72+
</td>
73+
</tr>
74+
</table>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# gat_v2.graph_update_get_config_dict
2+
3+
[TOC]
4+
5+
<!-- Insert buttons and diff -->
6+
7+
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
8+
<td>
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gat_v2/config_dict.py#L22-L39">
10+
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
11+
View source on GitHub
12+
</a>
13+
</td>
14+
</table>
15+
16+
Returns ConfigDict for graph_update_from_config_dict() with defaults.
17+
18+
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
19+
<code>gat_v2.graph_update_get_config_dict() -> config_dict.ConfigDict
20+
</code></pre>
21+
22+
<!-- Placeholder for "Used in" -->

tensorflow_gnn/docs/api_docs/python/models/gcn/GCNConv.md

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
88
<td>
9-
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gcn/gcn_conv.py#L28-L218">
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gcn/gcn_conv.py#L26-L279">
1010
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
1111
View source on GitHub
1212
</a>
@@ -23,11 +23,11 @@ Implements the Graph Convolutional Network by Kipf&Welling (2016).
2323
activation=&#x27;relu&#x27;,
2424
use_bias: bool = True,
2525
add_self_loops: bool = False,
26-
normalize: bool = True,
27-
kernel_initializer: bool = None,
26+
kernel_initializer: Any = None,
2827
node_feature: Optional[str] = tfgnn.HIDDEN_STATE,
29-
kernel_regularizer: Optional[_RegularizerType] = None,
28+
kernel_regularizer: Any = None,
3029
edge_weight_feature_name: Optional[tfgnn.FieldName] = None,
30+
degree_normalization: str = &#x27;in_out&#x27;,
3131
**kwargs
3232
)
3333
</code></pre>
@@ -36,7 +36,40 @@ Implements the Graph Convolutional Network by Kipf&Welling (2016).
3636

3737
This class implements a Graph Convolutional Network from
3838
https://arxiv.org/abs/1609.02907 as a Keras layer that can be used as a
39-
convolution on an edge set in a tfgnn.keras.layers.NodeSetUpdate.
39+
convolution on an edge set in a tfgnn.keras.layers.NodeSetUpdate. The original
40+
algorithm proposed in the Graph Convolutional Network paper expects a symmetric
41+
graph as input. That is, if there is an edge from node i to node j, there is
42+
also an edge from node j to node i. This implementation, however, is able to
43+
take asymmetric graphs as input.
44+
45+
Let $w_{ij}$ be the weight of the edge from sender i to receiver j. Let
46+
$\deg^{in}_i$ be the number of incoming edges to i (in the direction of message
47+
flow, see `receiver_tag`), and $\deg^{out}_i$ the number of outgoing edges from
48+
i. In a symmetric graphs, both are equal.
49+
50+
In this implementation, we provide multiple approaches for normalizing an edge
51+
weight $w_{ij}$ in $v_{ij}$, namely `"none"`, `"in"`, `"out"`, `"in_out"`, and
52+
`"in_in"`. Setting normalization to `"none"` will end up in set $v_{ij} =
53+
w_{ij}$. The `"in"` normalization normalizes edge weights using the in-degree of
54+
the receiver node, that is:
55+
56+
$$v_{ij} = w_{ij} / \deg^{in}_j.$$
57+
58+
The `"out"` normalization normalizes edges using the out-degree of sender nodes
59+
that is:
60+
61+
$$v_{ij} = w_{ij} / \deg^{out}_i.$$
62+
63+
The `"in_out"` normalization normalizes edges as follows:
64+
65+
$$v_{ij} = w_{ij} / (\sqrt{\deg^{out}_i} \sqrt{\deg^{in}_j}).$$
66+
67+
The `"in_in"` normalization normalizes the edge weights as:
68+
69+
$$v_{ij} = w_{ij} / (\sqrt{\deg^{in}_i} \sqrt{\deg^{in}_j}).$$
70+
71+
For symmetric graphs (as in the original GCN paper), `"in_out"` and `"in_in"`
72+
are equal, but the latter needs to compute degrees just once.
4073

4174
<!-- Tabular view -->
4275
<table class="responsive fixed orange">
@@ -90,17 +123,13 @@ with an edge weight of one.
90123
</td>
91124
</tr><tr>
92125
<td>
93-
`normalize`<a id="normalize"></a>
94-
</td>
95-
<td>
96-
Whether to normalize the node features by in-degree.
97-
</td>
98-
</tr><tr>
99-
<td>
100126
`kernel_initializer`<a id="kernel_initializer"></a>
101127
</td>
102128
<td>
103-
initializer of type tf.keras.initializers .
129+
Can be set to a `kernel_initializer` as understood
130+
by `tf.keras.layers.Dense` etc.
131+
An `Initializer` object gets cloned before use to ensure a fresh seed,
132+
if not set explicitly. For more, see `tfgnn.keras.clone_initializer()`.
104133
</td>
105134
</tr><tr>
106135
<td>
@@ -120,6 +149,14 @@ it as the edge's entry in the adjacency matrix, instead of the default 1.
120149
</td>
121150
</tr><tr>
122151
<td>
152+
`degree_normalization`<a id="degree_normalization"></a>
153+
</td>
154+
<td>
155+
Can be set to `"none"`, `"in"`, `"out"`, `"in_out"`,
156+
or `"in_in"`, as explained above.
157+
</td>
158+
</tr><tr>
159+
<td>
123160
`**kwargs`<a id="**kwargs"></a>
124161
</td>
125162
<td>

tensorflow_gnn/docs/api_docs/python/models/gcn/GCNHomGraphUpdate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<table class="tfo-notebook-buttons tfo-api nocontent" align="left">
88
<td>
9-
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gcn/gcn_conv.py#L221-L278">
9+
<a target="_blank" href="https://github.com/tensorflow/gnn/tree/master/tensorflow_gnn/models/gcn/gcn_conv.py#L282-L338">
1010
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
1111
View source on GitHub
1212
</a>

0 commit comments

Comments
 (0)