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.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad0ec6eafa0a07827115e1ae22b50cea77195b9dc4cb7c7723e62bdcdecedbc5 |
|
MD5 | d80d93ffc420e458a8208700bdebcc39 |
|
BLAKE2b-256 | 4b581267efefa2cc1659f0b1d682fa6f9214322117284f75404b3740efb95333 |
Hashes for pgl-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3439e69d7ce7e4a71707555510396460e041afef1bd3f702eb98adbc2a34a44b |
|
MD5 | aed6d641fb834394ac603f56013e8fa8 |
|
BLAKE2b-256 | e671424c8f50d1fb929027648089dc397cacc8b67381df29777d42ede540a4c1 |
Hashes for pgl-2.1.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 570ccd497985f4f3c839165d50af678306ad1bb81e98ff841ca659ed3f10f92e |
|
MD5 | 60ea7a8c4fb3501282ab72327d5c9749 |
|
BLAKE2b-256 | 26c35ab60b661e4c4e7b4d497dd3d0be98ef7c9061301607227b8672a89dc973 |
Hashes for pgl-2.1.3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c96f0d898d0b3750f4a14395f7a87def1f3a4ba7a45099455aa0317cce9398a |
|
MD5 | 754cf669cfbcda0c2f82cada12e3cfef |
|
BLAKE2b-256 | 995f83af5c8d3131434264bc159660bff48367e39c6f175752142428b9efe5a9 |
Hashes for pgl-2.1.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5534d366db8891a84617930115a1ec135337ef9d7a8a4e9e2eba2eb96d7c12f |
|
MD5 | 6468dd8e18cfec73ff8835f670e07fe8 |
|
BLAKE2b-256 | dddc3d932643aa2566d5bb92fbd0f14ca4f41893503cb4b03d946508e9ce3405 |
Hashes for pgl-2.1.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4a46a42111e78131b399f37888bb3676ec5e6f3f8c2341ccc748353a7125fd5 |
|
MD5 | e3696941da88228f7a6f9f6b9f095e9a |
|
BLAKE2b-256 | fa07b546183a93d4e6f6f91826833a2ff6ca0b865de1e5f392f27ab0d8f9ff83 |
Hashes for pgl-2.1.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2781087056f0d3c98d0313fd82f0f8455aa1f24e20531726b720836fa117a1f |
|
MD5 | c287160aa2bfc3bd9bcc6a3054694648 |
|
BLAKE2b-256 | b8a8b228eeef3c00e021ba58918e813c25d5d7bc71854480e63a869267085968 |
Hashes for pgl-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8ead36da239f244c8a36837d4ebb6f1f3f523340b8ccec41384a0716a567ab0 |
|
MD5 | da029119dfbd810157c892e494c6fad3 |
|
BLAKE2b-256 | 8f379612cf44d56da6a6cd289a6db28f427d5d8d99a2ff798255677893d4726e |
Hashes for pgl-2.1.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c1d2beebd3cef69614a6539ae0bb7b141e08b19e6d1e3c3a6dc4eb607c8655d |
|
MD5 | 7d64ebff147942a4e912b50835929d5e |
|
BLAKE2b-256 | 1a251f721ae3ccdaf3a724bbee7a0360e77b4bab0f19c0dcfbbdc893a9d3f5d0 |
Hashes for pgl-2.1.3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6649a7235ff6635422975df8e62b4470a26bf0b6dd3390fd2769070cad32d90 |
|
MD5 | d5bf461ef881174a749101cbde74e1ba |
|
BLAKE2b-256 | 9994c656e03dc3769330f3c2aac33dbca67922fc0c175d18adadfab2da27303b |
Hashes for pgl-2.1.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87d579d2d42c6b2a61357f2230cfb178ce9b2a3cf634d58fbf7fdee9975bfaf5 |
|
MD5 | 00a3bc6d7c683f2f42403a35eccaf213 |
|
BLAKE2b-256 | 2bd06736a583510fd0c439ffba08a1b5515cd05a32d529a6b2ecc874da864d8c |
Hashes for pgl-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 874b5009a1ab5ac293c13f387b9ba07f160ccfe1c1321ed7d293b401bacbb39c |
|
MD5 | f8057a99eaa59ecb6eda236444332e98 |
|
BLAKE2b-256 | 2c6f068f3b27813328683c09ba19bbc72e84ac0eaddf8533d7b2539a537c68d2 |
Hashes for pgl-2.1.3-cp37-cp37m-macosx_10_9_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4febd321516f1553e0a698c468535f3057dfd73c4dd1b7a1cc1e6717cee3bbfc |
|
MD5 | 76e0555d369da3485be08aa913bd427a |
|
BLAKE2b-256 | 6c3051e234f9e39aa43686c99f5bacf4ef25ba845a1307351448319eb511edca |
Hashes for pgl-2.1.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e0aa269874dd2b26ad4de2c8f1a64e3b8f1aed28c1419ee7085d68e7f8211b1 |
|
MD5 | a62d881f64aeea4c38bdecad145b7b27 |
|
BLAKE2b-256 | ffa191325e4161397abb512bc9bcdf7edbce887ff9dc3df2c5cc2446582b9f31 |
Hashes for pgl-2.1.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82f55572b5dd30084c3f18d93acc1562cb2e92df046e6082bb89ac7a4214a8a4 |
|
MD5 | 8fdd910e0b3b875190ca8be923b57ec3 |
|
BLAKE2b-256 | 4808778e2aec0a6f65f0e81b43b19555d8359408f8c2904f95b5a4ae723dc86f |
Hashes for pgl-2.1.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7deec796c617940081dc282eaf9a11e84b8815e0f8b033ba342a49885a3493e |
|
MD5 | d0d33aec839233f5ab58bd0f7192ce3c |
|
BLAKE2b-256 | ff75ef6b91563e09e3530c58638770ae7ac2440810e0f15227be7481d72b1ba2 |
Hashes for pgl-2.1.3-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b69fac3deaed99ea0de92292e20b9353aec96ca6c7b9d143e128ff7cd0612503 |
|
MD5 | 78be7e84a5a33dd631b59803ed2aaf05 |
|
BLAKE2b-256 | d3f35d20007a430f19381a5a1655769c1ac6dc632f87be6ef04bc3ab7b7c4023 |
Hashes for pgl-2.1.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 954a18f6b5f3cf65dcdeabf8b2f681e2099a3b310eb91996306d330da1f92b5d |
|
MD5 | af090f6969a9b09fba4ab54555d6b87a |
|
BLAKE2b-256 | 8b087b3d422fa37500c5133d7e936dda9daa74168967e4923992c4bf64c014af |
Hashes for pgl-2.1.3-cp36-cp36m-macosx_10_9_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7c17022bb9b5265b56afc7192c96a025d04e8a790ffc852b8fe8b924993380 |
|
MD5 | 8961ebbfeeee078a730629ddff1d3d5b |
|
BLAKE2b-256 | 48b509ef8a5c1a77a3c779b16655e343b4f1c2552818552556ff083685bfe1b3 |