Skip to content

Commit 0ab9440

Browse files
committed
Fixed error for reverse indices and changed GraphNumpyContainer into Alias. Simplified name of default entries.
1 parent 1ea5bb8 commit 0ab9440

File tree

6 files changed

+187
-131
lines changed

6 files changed

+187
-131
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,22 @@ A major issue for graphs is their flexible size and shape, when using mini-batch
8282

8383
### Input
8484

85-
Here, for ragged tensors, the nodelist of shape `(batch, None, F)` and edgelist of shape `(batch, None, F')` have one ragged dimension `(None, )`.
86-
The graph structure is represented by an index-list of shape `(batch, None, 2)` with index of incoming or receiving node `i` and outgoing or sending node `j` as `(i, j)`.
87-
The first index of incoming node `i` is usually sorted for faster pooling operations, but can also be unsorted.
88-
Furthermore, the graph is directed, so an additional edge with `(j, i)` is required for undirected graphs.
89-
A ragged constant can be directly obtained from a list of numpy arrays: `tf.ragged.constant(indices, ragged_rank=1, inner_shape=(2, ))` which yields shape `(batch, None, 2)`.
85+
Graph tensors for edge-indices or attributes for multiple graphs is passed to the model in form of ragged tensors
86+
of shape `(batch, None, Dim)` where `Dim` denotes a fixed feature or index dimension.
87+
Such a ragged tensor has `ragged_rank=1` with one ragged dimension indicated by `None` and is build from a value and partition tensor.
88+
For example, the graph structure is represented by an index-list of shape `(batch, None, 2)` with index of incoming or receiving node `i` and outgoing or sending node `j` as `(i, j)`.
89+
Note, an additional edge with `(j, i)` is required for undirected graphs.
90+
A ragged constant can be easily created and passed to a model:
91+
92+
```python
93+
import tensorflow as tf
94+
import numpy as np
95+
idx = [[[0, 1], [1, 0]], [[0, 1], [1, 2], [2, 0]], [[0, 0]]] # batch_size=3
96+
# Get ragged tensor of shape (3, None, 2)
97+
print(tf.ragged.constant(idx, ragged_rank=1, inner_shape=(2, )).shape)
98+
print(tf.RaggedTensor.from_row_lengths(np.concatenate(idx), [len(i) for i in idx]).shape)
99+
```
100+
90101

91102
### Model
92103

0 commit comments

Comments
 (0)