propago
Graph neural network layers.
Quickstart
[]
= "0.2"
= { = "0.20", = false, = ["std"] }
= "0.20"
Hyperbolic distance on the Poincare ball:
use ;
use NdArray;
use PoincareBall;
type B = ;
let dev = default;
let ball = new;
let x = from_data;
let y = from_data;
let d = ball.distance.to_data..unwrap;
assert!;
Geometry
The Poincare ball $\mathbb{B}^d_c = {x \in \mathbb{R}d : c\lVert x \rVert2 < 1}$ with curvature $-c$:
| Operation | Formula |
|---|---|
| Distance | $d_c(x, y) = \frac{2}{\sqrt{c}} \text{arctanh}\bigl(\sqrt{c}\lVert -x \oplus_c y \rVert\bigr)$ |
| Mobius addition | $x \oplus_c y = \frac{(1 + 2c\langle x,y\rangle + c\lVert y\rVert2)x + (1 - c\lVert x\rVert2)y}{1 + 2c\langle x,y\rangle + c2\lVert x\rVert2\lVert y\rVert^2}$ |
| Exp map | $\exp_xc(v) = x \oplus_c \bigl(\tanh\bigl(\frac{\sqrt{c}\lambda_xc\lVert v\rVert}{2}\bigr)\frac{v}{\sqrt{c}\lVert v\rVert}\bigr)$ |
| Log map | $\log_xc(y) = \frac{2}{\sqrt{c}\lambda_xc}\text{arctanh}(\sqrt{c}\lVert -x \oplus_c y\rVert)\frac{-x \oplus_c y}{\lVert -x \oplus_c y\rVert}$ |
where $\lambda_xc = \frac{2}{1 - c\lVert x\rVert2}$ is the conformal factor.
API surface
propago::PoincareBall: Poincare ball geometry (project, mobius_add, exp/log maps, distance, parallel transport).propago::GCNConv: graph convolution (linear projection + adjacency matmul).propago::HGCNConv: hyperbolic graph convolution on the Poincare ball.
Inputs are shaped [batch, d] (row-major feature vectors).
License
MIT OR Apache-2.0