torch_geometric API documentation¶
Requires the optional dependency: pip install gsxform[pyg].
GraphScattering ¶
GraphScattering(transform)
Bases: Module
Run a scattering transform on torch_geometric's sparse batch layout.
Wraps any ScatteringTransform so it takes the usual PyG inputs: node
features [N_total, F], edge_index, and the batch vector. Graphs of
different sizes are padded to a common node count and masked internally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transform
|
ScatteringTransform
|
Scattering transform to apply, e.g. |
required |
Source code in gsxform/pyg.py
31 32 33 34 35 36 37 38 39 40 | |
forward ¶
forward(x, edge_index, batch=None, edge_weight=None)
Compute scattering features for a batch of graphs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Node features, shaped [N_total, F] |
required |
edge_index
|
Tensor
|
Edges, shaped [2, E] |
required |
batch
|
Tensor | None
|
Graph assignment of each node, shaped [N_total] and sorted, as
produced by PyG's |
None
|
edge_weight
|
Tensor | None
|
Weight of each edge, shaped [E]. Defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
[B, F * n_coefficients] for graph output, or [N_total, F * n_coefficients] for node output, feature-major. With moment aggregation, each coefficient contributes one column per moment. |
Source code in gsxform/pyg.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
ScatteringFeatures ¶
ScatteringFeatures(transform, attr='scattering')
Bases: BaseTransform
Precompute scattering features as a torch_geometric dataset transform.
Stores the scattering representation of each graph on the Data object,
so a fixed transform is computed once per graph rather than every epoch,
Graph output is stored shaped [1, D], so DataLoader batches it to [B, D];
node output is stored shaped [N, D].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transform
|
ScatteringTransform
|
Scattering transform to apply, e.g. |
required |
attr
|
str
|
Name of the attribute the features are stored under. Defaults to "scattering" |
'scattering'
|
Source code in gsxform/pyg.py
104 105 106 107 108 109 110 111 112 113 114 115 116 | |
forward ¶
forward(data)
Add scattering features to one graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Data
|
Graph with node features |
required |
Returns:
| Type | Description |
|---|---|
Data
|
The same graph, with the features stored under |
Source code in gsxform/pyg.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |