pycsamt.ai.nets.gcn#

Graph Convolutional Network for spatial EM inversion.

GCNNet implements Kipf & Welling (2017) spectral graph convolutions adapted for geophysical data:

\(H^{(l+1)} = \sigma\!\left(\tilde{D}^{-1/2} \tilde{A}\tilde{D}^{-1/2} H^{(l)} W^{(l)}\right)\)

where \(\tilde{A} = A + I\) (self-loops), \(\tilde{D}_{ii} = \sum_j \tilde{A}_{ij}\).

No external graph library (PyTorch Geometric, DGL) is required; the normalised adjacency matrix is pre-computed once from station coordinates and passed as a dense tensor to every forward call.

Functions

build_adjacency(coords, radius, *[, ...])

Build a symmetric adjacency matrix from 2-D station coordinates.

Classes

GCNNet(n_features, n_out[, hidden, dropout])

Factory that builds a PyTorch or TensorFlow GCN.

class pycsamt.ai.nets.gcn.GCNNet(n_features, n_out, hidden=(256, 128, 64), dropout=0.1)[source]#

Bases: object

Factory that builds a PyTorch or TensorFlow GCN.

Call build() after import to obtain the framework module.

Parameters:
  • n_features (int) – Dimensionality of per-node input features (e.g. 2 × n_freqs).

  • n_out (int) – Per-node output size (2n-1 for an n-layer model: n resistivities + n-1 thicknesses).

  • hidden (sequence of int) – Hidden-layer widths for each GCN message-passing step.

  • dropout (float) – Dropout probability applied after each hidden GCN layer.

build()[source]#

Return a torch.nn.Module for this architecture.

Return type:

torch.nn.Module

build_tf()[source]#

Return a tf.keras.Model for this architecture.

Return type:

tf.keras.Model

pycsamt.ai.nets.gcn.build_adjacency(coords, radius, *, self_loops=True, normalise=True)[source]#

Build a symmetric adjacency matrix from 2-D station coordinates.

Parameters:
  • coords (ndarray, shape (n_stations, 2)) – Station (x, y) positions in any consistent unit (metres, degrees).

  • radius (float) – Maximum inter-station distance for an edge to exist. Uses the same unit as coords.

  • self_loops (bool) – If True (default), add \(\tilde{A} = A + I\).

  • normalise (bool) – If True (default), apply symmetric normalisation \(\tilde{D}^{-1/2}\tilde{A}\tilde{D}^{-1/2}\).

Returns:

A – Adjacency matrix, optionally normalised.

Return type:

ndarray, shape (n_stations, n_stations), float32