GithubHelp home page GithubHelp logo

graphnet_amg's Introduction

graphnet_amg

Graph net boosted prolongation operator for algebraic multigrid

This code trains a graph neural network to select the interpolation weights in the prolongation operator for transporting errors between grids in the algebraic multigrid (AMG) algorithm. Our work is mostly based on Luz et al. (see paper at https://arxiv.org/abs/2003.05744 and repository at https://github.com/ilayluz/learning-amg.git) and Moore et al. (see paper at https://doi.org/10.2172/1859673).

AMG is an iterative algorithm for solving large and sparse linear systems that arise from, for example, discretisation of partial differential equations (PDEs). In each iteration, high frequency errors are eliminated by a classic relaxation scheme (commonly Gauss-Seidel), whereas low-frequency errors (i.e. smooth errors) are transferred onto a coarser grid where the smooth errors can be more efficiently removed by further relaxation sweeps. Multiple levels of such grids of increasing coarseness can be used for reducing the error. The interpolation operators transport errors between adjacent grid levels.

The coefficient matrix of a coarse grid, A_coarse, is commonly generated by the standard Galerkin projection: A_coarse = R * A * P = P_transpose * A * P, where the restriction matrix R (fine->coarse grid) is just the transpose of the prolongation matrix P (coarse->fine grid). P and R are the interpolation operators.

In particular, we use a neural network to help build the prolongation operator P that interpolates errors from a coarse grid to a fine one. This is done with the information of the coefficient matrix A of the finest grid, and the standard prolongation operator P_baseline generated by a traditional method. Although the sparsity pattern of P is enforced to be the same as P_baseline, the non-zero values (interpolation weights) in P are optimised through the neural network. Let matrix M describe the error propagation from one iteration to another by e_(i+1) = M * e_i, then the goal of an optimal P is to minimise M. In AMG, M = S_s1 * C * S_s2. S_s1 and S_s2 are the relaxation operators applied on the finest grid, before and after the cycle through the coarse grids, where s1 and s2 refer to the number of relaxation sweeps and are both typically 1 or 2. C represents the error reduction achieved through the coarse grids. C = I โˆ’ P * [P_transpose * A * P]^(โˆ’1) * P_transpose * A. Given S_s1 and S_s2, which themselves typically do not have much room to be optimised, the choice of P determines the efficiency of error reduction per iteration. We use the Frobenius norm of M as the loss function of P.

The objective of the neural network can be summarised as follows: given A and P_baseline, train P to minimise M. A is a matrix of size mxm, where m is the dimension of the unknowns in the linear system, i.e. the number of nodes in the finest grid. P_baseline is a matrix of size mxn, where n is the number of nodes in the coarser grid. n<m and typically n~m/2. P takes the same dimension and sparsity pattern of P_baseline. The problem can be naturally represented by a graph neural network where A is the adjacency matrix. The elements of A are an edge feature, representing the level of influence/dependency between two vertices. In our case, these elements represent the "closeness" of nodes, a concept that is natural in a geometrical multigrid problem but needs to be defined analogously in an algebraic multigrid problem. The GN then needs to output a graph with updated edge features. The output graph has the same dimensions as the input graph. But with a few simple steps, the new edge features can be used to form the non-zero elements of P.

AMG methods are originally developed for As that are M-matrices, which are matrices that are symmetric and positive definite with positive entries on the diagonal and nonpositive off-diagonal entries. This assumption is not necessary for AMG to work, but standard AMG is less likely to be effective if As are far from M-matrices. In Luz et al.'s work, As are chosen to be sparse symmetric positive definite or semi-definite matrices.

How to get started on Snellius, the Dutch national supercomputer

module purge
module load 2021
module load TensorFlow/2.6.0-foss-2021a-CUDA-11.3.1

python -m venv amg_venv
source amg_venv/bin/activate

pip install -r requirements.txt

Training

python graphnet_amg.py

Test

python test_model.py

Model checkpoint is saved at 'training_dir/model_id'.

Tensorboard log files are outputted to 'tb_dir/model_id'.

graphnet_amg's People

Contributors

yuezhao6371 avatar mooon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.