Paddle Graph Learning
Project description
DOC | Quick Start | 中文
Breaking News !!
PGL v2.1 20210202
- We are now support dygraph version of PaddlePaddle 2.0, and release PGL v2.1.
- You can find the stable staic version of PGL in the branch "static_stable"
PGL v1.2 2020.11.20
-
The PGL team proposed a new Unified Message Passing Model (UniMP), and achieved the State of the Art on three tasks on the OGB leaderboards. You can find the code here.
-
The PGL team proposed a two-stage recall and ranking model based on ERNIEsage, and won the first place in the TextGraphs-2020 competition co-organized by COLING.
-
The PGL team worked hard to develop an open course of Graph Neural Network (GNN), which will help you getting started with Graph Neural Network in seven days. Details can be found in course.
PGL v1.1 2020.4.29
-
You can find ERNIESage, a novel model for modeling text and graph structures, and its introduction here.
-
PGL for Open Graph Benchmark examples can be found here.
-
We add newly graph level operators like GraphPooling and GraphNormalization for graph level predictions.
-
We relase a PGL-KE toolkit here including classical knowledge graph embedding t algorithms like TransE, TransR, RotatE.
Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on PaddlePaddle.
The newly released PGL supports heterogeneous graph learning on both walk based paradigm and message-passing based paradigm by providing MetaPath sampling and Message Passing mechanism on heterogeneous graph. Furthermor, The newly released PGL also support distributed graph storage and some distributed training algorithms, such as distributed deep walk and distributed graphsage. Combined with the PaddlePaddle deep learning framework, we are able to support both graph representation learning models and graph neural networks, and thus our framework has a wide range of graph-based applications.
One of the most important benefits of graph neural networks compared to other models is the ability to use node-to-node connectivity information, but coding the communication between nodes is very cumbersome. At PGL we adopt Message Passing Paradigm similar to DGL to help to build a customize graph neural network easily. Users only need to write send
and recv
functions to easily implement a simple GCN. As shown in the following figure, for the first step the send function is defined on the edges of the graph, and the user can customize the send function to send the message from the source to the target node. For the second step, the recv function
is responsible for aggregating
messages together from different sources.
To write a sum aggregator, users only need to write the following codes.
import pgl
import paddle
import numpy as np
num_nodes = 5
edges = [(0, 1), (1, 2), (3, 4)]
feature = np.random.randn(5, 100).astype(np.float32)
g = pgl.Graph(num_nodes=num_nodes,
edges=edges,
node_feat={
"h": feature
})
g.tensor()
def send_func(src_feat, dst_feat, edge_feat):
return src_feat
def recv_func(msg):
return msg.reduce_sum(msg["h"])
msg = g.send(send_func, src_feat=g.node_feat)
ret = g.recv(recv_func, msg)
Highlight: Flexibility - Natively Support Heterogeneous Graph Learning
Graph can conveniently represent the relation between things in the real world, but the categories of things and the relation between things are various. Therefore, in the heterogeneous graph, we need to distinguish the node types and edge types in the graph network. PGL models heterogeneous graphs that contain multiple node types and multiple edge types, and can describe complex connections between different types.
Support meta path walk sampling on heterogeneous graph
The left side of the figure above describes a shopping social network. The nodes above have two categories of users and goods, and the relations between users and users, users and goods, and goods and goods. The right of the above figure is a simple sampling process of MetaPath. When you input any MetaPath as UPU (user-product-user), you will find the following results Then on this basis, and introducing word2vec and other methods to support learning metapath2vec and other algorithms of heterogeneous graph representation.
Support Message Passing mechanism on heterogeneous graph
Because of the different node types on the heterogeneous graph, the message delivery is also different. As shown on the left, it has five neighbors, belonging to two different node types. As shown on the right of the figure above, nodes belonging to different types need to be aggregated separately during message delivery, and then merged into the final message to update the target node. On this basis, PGL supports heterogeneous graph algorithms based on message passing, such as GATNE and other algorithms.
Large-Scale: Support distributed graph storage and distributed training algorithms
In most cases of large-scale graph learning, we need distributed graph storage and distributed training support. As shown in the following figure, PGL provided a general solution of large-scale training, we adopted PaddleFleet as our distributed parameter servers, which supports large scale distributed embeddings and a lightweighted distributed storage engine so it can easily set up a large scale distributed training algorithm with MPI clusters.
Model Zoo
The following graph learning models have been implemented in the framework. You can find more examples and the details here.
Model | feature |
---|---|
ERNIESage | ERNIE SAmple aggreGatE for Text and Graph |
GCN | Graph Convolutional Neural Networks |
GAT | Graph Attention Network |
GraphSage | Large-scale graph convolution network based on neighborhood sampling |
unSup-GraphSage | Unsupervised GraphSAGE |
LINE | Representation learning based on first-order and second-order neighbors |
DeepWalk | Representation learning by DFS random walk |
MetaPath2Vec | Representation learning based on metapath |
Node2Vec | The representation learning Combined with DFS and BFS |
Struct2Vec | Representation learning based on structural similarity |
SGC | Simplified graph convolution neural network |
GES | The graph represents learning method with node features |
DGI | Unsupervised representation learning based on graph convolution network |
GATNE | Representation Learning of Heterogeneous Graph based on MessagePassing |
The above models consists of three parts, namely, graph representation learning, graph neural network and heterogeneous graph learning, which are also divided into graph representation learning and graph neural network.
System requirements
PGL requires:
- paddle >= 2.0.0
- cython
PGL only supports Python 3
Installation
You can simply install it via pip.
pip install pgl
The Team
PGL is developed and maintained by NLP and Paddle Teams at Baidu
E-mail: nlp-gnn[at]baidu.com
License
PGL uses Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pgl-2.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fba3d952cc50c452dd58dd0f25e9fedb34ea1710c7ed8813c340952e7f64da7 |
|
MD5 | a6fb4665a3e9c81667345b1bf0e1ee1b |
|
BLAKE2b-256 | 9f2552a6aed9582c04c5715d2cdc30fbc1fd468b3018bcdea3f30a62960e3adb |
Hashes for pgl-2.1.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65c15889767b371b857e3c20aba6709bc0ce707fcb7768857b904f0c39083ca |
|
MD5 | 3e50bc38c92fbe2e5c12cb7833aa8b7d |
|
BLAKE2b-256 | fbefbac0ea4dade5beadfc79e1c8a02e34f42e8dffdc37ba3984da28fe1d71dd |
Hashes for pgl-2.1.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a85e138dc58a5ba2f24e662b3bc9845b5e39838cc6c682905c3d2f84661c1d63 |
|
MD5 | 2f26c44a53fbfb2baeab5039dfec6ef9 |
|
BLAKE2b-256 | 428c99f802fa54b3071582855848bfeb04d63b6b1657297ec48031dc738ae862 |
Hashes for pgl-2.1.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5a0b357b918595ba684c037f7592f0a2c394c3e7fe6e216959d5053b5a0002a |
|
MD5 | 6f6ad73c83cae966a65769f32966147a |
|
BLAKE2b-256 | 8bc3ad8f3f8ce69351a6113d4ff7ea296136c55dbce9550a6dbe19facd972b18 |
Hashes for pgl-2.1.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b438866bf31a837242e9ca63a9af153f0f5d368f415af5ce203ce0cc1d86464 |
|
MD5 | 115af998646962b3bdc5d7480476a682 |
|
BLAKE2b-256 | 841ce2d6e19d3f4ef32b64a44b862ce7aa56495ffc244e84176780974ccaa3b9 |
Hashes for pgl-2.1.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c05c050716d904713d322462fd26c70bf6fc4f65f2c02aaafd695fbe46c4131b |
|
MD5 | 70987c0318f52496fe76cc0a21b7f2d2 |
|
BLAKE2b-256 | da0860456a86c010c89d3c78bf2e1e925e9e7830066f4e4b708f2747597c4477 |
Hashes for pgl-2.1.2-cp37-cp37m-macosx_10_9_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af17d55a16e5ed9883b0fccb0c6d346265c6f7e3d9a6c89aef38291c3d1d69e4 |
|
MD5 | fea59d881a8f44a8e7c1dc3467da28bb |
|
BLAKE2b-256 | 3abcaa25b163b847bf9e2cbf0ec526325e0ad93edae5f908070b345f73abb9f1 |
Hashes for pgl-2.1.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de0839def5d248a49796c57d97f6cab90370d16edc3a049f32ba123b88c1ce9a |
|
MD5 | 81e261b395c3e6f8e258623cf59a79bd |
|
BLAKE2b-256 | 076dc2ee465e7765cb64ab9e30a0ca715d9322cc05313ee1ce691ef7c122618b |
Hashes for pgl-2.1.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c0dfbb642df40888e4f7dea0f17aa816c8f75fa3f64534deb3164b5ce17432b |
|
MD5 | 0a9a8d65facfdea52f63c24cdc8bbdf3 |
|
BLAKE2b-256 | d18895a3c134bbc79cee4c0aa379dd3fd646295e9532d87c307ddd32746c14bd |
Hashes for pgl-2.1.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5868d6eb70c4546b6ee559d8f6cfe9fc51e1d854badee7e8bf8b5ef67e2a5f92 |
|
MD5 | 891f73486939bc23b78cb93205539d53 |
|
BLAKE2b-256 | 81b22d6388c0223f9a5dd324d5a59a79922bd2d0f169de0d0cfe52c4feae54c1 |