Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Examples


GNP models can be instantiated using the GNP model class:

from gnp.models import GNP

full_model = GNP(
    node_dim=3,
    edge_dim=6,
    out_dim=1,
    layers=[64] * 10,
    conv_name="GraphConvolution",
    conv_args={"neurons": 128},
    nonlinearity="ReLU",
    skip_connection=True,
    device="cuda",
)

See how to load more variants of the GNP in our Example Code

Pretrained models are loaded when instantiatiating the GeometryEstimator class. This can be used to gather geometric quantities and more by instantiating:

import numpy as np
import torch
from gnp import GeometryEstimator
pcd = torch.from_numpy(np.load('example_data/spot/xyz.npy'))
orientation = torch.from_numpy(np.load('example_data/spot/normals.npy'))
estimator = GeometryEstimator(pcd=pcd,
                              orientation=orientation,
                              model_name='clean_30k')

GNPs for Estimating Curvatures

Geometric quantities can be easily generated using

outputs = estimator.estimate_quantities(['mean_curvature', 'gaussian_curvature'])


See our example code.


GNPs for Solving PDEs on Manifolds

A stiffness matrix for the Laplace-Beltrami equation $-\Delta_{\text{LB}} u = f$ using Generalized Moving Least Squares (GMLS) can be constructed

stiffness_matrix, collocation_mask, outlier_mask = estimator.stiffness_matrix_gmls(
    drop_ratio=0.1, radius=1, p=4, remove_outliers=False
)


This can be paired with your favorite linear solvers and/or preconditioners. We use Scipy's LGMRES and PyAMG for preconditioning. See our collocation example code


GNPs for Curvature Driven Flows

Mean curvature flows (MCF) can be simulated using

flow_data = estimator.mean_flow(
    num_steps=250,
    save_data_per_step=25,
    delta_t=0.0002,
    subsample_radius=0.005,
    smooth_radius=0.06,
    smooth_x=False,
)


See our example code.


GNP Curvature Estimation: Training Example

We show a standalone example of how to train a Geometric Neural Operator (PatchGNP) from scratch to estimate surface curvatures on 3D point clouds.

Overview

The script train_curvature_estimator.py:

  1. Generates synthetic surfaces -- analytically extracted mean and Gaussian curvatures as ground truth (GT).

    Example surfaces: -- (i) unit sphere, (ii) torus, (iii) paraboloid.

  2. Trains a PatchGNP model end-to-end using MSE loss on both mean and gaussian curvature types.

    Remark: The model learns Legendre polynomial coefficients for local surface patches; curvatures are computed differentiably from those coefficients via the standard first and second fundamental forms.

  3. Evaluates the trained model on each test surface to obtain the mean absolute errors of the curvature estimates.

Training

python train_curvature_estimator.py --epochs 1000 --num_points 15000 \
  --num_patches 64 --device cuda

See our training example code.