Home Technology peripherals AI 10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

Apr 11, 2023 pm 11:52 PM
machine learning code

In 2019, New York University and Amazon Cloud Technology jointly launched the graph neural network framework DGL (Deep Graph Library). Now DGL 1.0 is officially released! DGL 1.0 summarizes the various needs for graph deep learning and graph neural network (GNN) technology in academia or industry in the past three years. From academic research on state-of-the-art models to scaling GNNs to industrial applications, DGL 1.0 provides a comprehensive and easy-to-use solution for all users to better take advantage of graph machine learning.


10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

##DGL 1.0 for different scenarios solutions provided.

DGL 1.0 adopts a layered and modular design to meet various user needs. Key features of this release include:

  • More than 100 out-of-the-box GNN model examples, more than 15 top-ranked ones on Open Graph Benchmark (OGB) Baseline model;
  • More than 150 commonly used GNN modules, including GNN layers, data sets, graph data conversion modules, graph samplers, etc., which can be used to build new model architectures or GNN-based Solution;
  • Flexible and efficient message passing and sparse matrix abstraction for developing new GNN modules;
  • Multi-GPU and distributed Training capabilities support training on tens of billions of graphs.


10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

#DGL 1.0 Technology stack diagram

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0


##Address: https:/ /github.com/dmlc/dgl

One of the highlights of this version is the introduction of DGL-Sparse, a new programming interface that uses sparse matrices as the core programming abstraction. DGL-Sparse not only simplifies the development of existing GNN models such as graph convolutional networks, but also works with the latest models, including diffusion-based GNNs, hypergraph neural networks, and graph Transformers.

The release of DGL version 1.0 has aroused enthusiastic responses on the Internet. Scholars such as Yann Lecun, one of the three giants of deep learning, and Xavier Bresson, associate professor at the National University of Singapore, have all liked and forwarded it.

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0#In the following article, the author Two mainstream GNN paradigms are outlined, namely message passing view and matrix view. These paradigms can help researchers better understand the inner working mechanism of GNN, and the matrix perspective is also one of the motivations for the development of DGL Sparse.

Message passing view and matrix view

There is a saying in the movie "Arrival": "The language you use determines your The way you think and affects your view of things." This sentence also applies to GNN.

means that graph neural networks have two different paradigms. The first, called the message passing view, expresses the GNN model from a fine-grained, local perspective, detailing how messages are exchanged along edges and how node states are updated accordingly. The second is the matrix perspective. Since graphs have algebraic equivalence with sparse adjacency matrices, many researchers choose to express GNN models from a coarse-grained, global perspective, emphasizing operations involving sparse adjacency matrices and eigenvectors.

The message passing perspective reveals the connection between GNNs and the Weisfeiler Lehman (WL) graph isomorphism test, which also relies on aggregating information from neighbors. The matrix perspective understands GNN from an algebraic perspective, leading to some interesting discoveries, such as the over-smoothing problem.

In short, these two perspectives are indispensable tools for studying GNN. They complement each other and help researchers better understand and describe the nature and characteristics of GNN models. It is for this reason that one of the main motivations for the release of DGL 1.0 is to add support for the matrix perspective based on the existing message passing interface.

DGL Sparse: A sparse matrix library designed for graph machine learning

A new library called DGL Sparse has been added to DGL version 1.0 (dgl.sparse), together with the message passing interface in DGL, improves support for all types of graph neural network models. DGL Sparse provides sparse matrix classes and operations specifically for graph machine learning, making it easier to write GNNs from a matrix perspective. In the next section, the authors demonstrate several GNN examples, showing their mathematical formulations and corresponding code implementations in DGL Sparse.

Graph Convolutional Network

GCN is one of the pioneers of GNN modeling. GCN can be represented with both message passing view and matrix view. The following code compares the differences between these two methods in DGL.

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0


10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

#Implementing GCN using messaging API


10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

##Use DGL Sparse to implement GCN

GNN based on graph diffusion

Graph diffusion is the process of spreading or smoothing node features or signals along edges. Many classic graph algorithms such as PageRank fall into this category. A series of studies have shown that combining graph diffusion with neural networks is an effective and efficient way to enhance model predictions. The following equation describes the core calculation of one of the more representative models, APPNP. It can be implemented directly in DGL Sparse.

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

##Hypergraph Neural Network

Hypergraph is a generalization of graph where edges can connect any number of nodes (called hyperedges). Hypergraphs are particularly useful in scenarios where higher-order relationships need to be captured, such as co-purchasing behavior in e-commerce platforms, or co-authorship in citation networks. A typical feature of a hypergraph is its sparse correlation matrix, so hypergraph neural networks (HGNN) are often defined using sparse matrices. The following is a hypergraph convolutional network (Feng et al., 2018) and its code implementation.

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

#Graph Transformer

Transformer model has become the most successful model architecture in natural language processing. Researchers are also beginning to extend Transformer to graph machine learning. Dwivedi et al. pioneered the idea of ​​limiting all multi-head attention to connected pairs of nodes in the graph. This model can be easily implemented with only 10 lines of code using the DGL Sparse tool.

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0

Key Features of DGL Sparse

Compared with sparse matrix libraries such as scipy.sparse or torch.sparse, the overall design of DGL Sparse is to serve graph machine learning, which includes the following key features:

  • Automatic sparse format selection: DGL Sparse is designed so that users do not have to worry about choosing the correct data structure to store sparse matrices (also known as sparse formats). Users only need to remember that dgl.sparse.spmatrix creates a sparse matrix, and DGL will automatically select the optimal format internally based on the operator called;
  • # Scalar or vector non-zero elements : Many GNN models learn multiple weights on the edges (such as the multi-head attention vectors demonstrated in the Graph Transformer example). To accommodate this situation, DGL Sparse allows non-zero elements to have vector shapes and extends common sparse operations such as sparse-dense-matrix multiplication (SpMM), etc. You can refer to the bspmm operation in the Graph Transformer example.

By leveraging these design features, DGL Sparse reduced code length on average compared to the previous implementation of the matrix view model using a message passing interface. 2.7 times . The simplified code also reduces the framework's overhead by 43%. In addition, DGL Sparse is compatible with PyTorch and can be easily integrated with various tools and packages in the PyTorch ecosystem. Get started with DGL 1.0

DGL 1.0 has been released on all platforms and can be easily installed using pip or conda. In addition to the examples introduced earlier, the first version of DGL Sparse also includes 5 tutorials and 11 end-to-end examples, all of which can be experienced directly in Google Colab without the need for local installation.

To learn more about the new features of DGL 1.0, please refer to the author's release log. If you encounter any problems or have any suggestions or feedback while using DGL, you can also contact the DGL team through the Discuss forum or Slack.

The above is the detailed content of 10 lines of code to complete the graph Transformer, the graph neural network framework DGL ushered in version 1.0. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

This article will take you to understand SHAP: model explanation for machine learning This article will take you to understand SHAP: model explanation for machine learning Jun 01, 2024 am 10:58 AM

In the fields of machine learning and data science, model interpretability has always been a focus of researchers and practitioners. With the widespread application of complex models such as deep learning and ensemble methods, understanding the model's decision-making process has become particularly important. Explainable AI|XAI helps build trust and confidence in machine learning models by increasing the transparency of the model. Improving model transparency can be achieved through methods such as the widespread use of multiple complex models, as well as the decision-making processes used to explain the models. These methods include feature importance analysis, model prediction interval estimation, local interpretability algorithms, etc. Feature importance analysis can explain the decision-making process of a model by evaluating the degree of influence of the model on the input features. Model prediction interval estimate

Identify overfitting and underfitting through learning curves Identify overfitting and underfitting through learning curves Apr 29, 2024 pm 06:50 PM

This article will introduce how to effectively identify overfitting and underfitting in machine learning models through learning curves. Underfitting and overfitting 1. Overfitting If a model is overtrained on the data so that it learns noise from it, then the model is said to be overfitting. An overfitted model learns every example so perfectly that it will misclassify an unseen/new example. For an overfitted model, we will get a perfect/near-perfect training set score and a terrible validation set/test score. Slightly modified: "Cause of overfitting: Use a complex model to solve a simple problem and extract noise from the data. Because a small data set as a training set may not represent the correct representation of all data." 2. Underfitting Heru

Transparent! An in-depth analysis of the principles of major machine learning models! Transparent! An in-depth analysis of the principles of major machine learning models! Apr 12, 2024 pm 05:55 PM

In layman’s terms, a machine learning model is a mathematical function that maps input data to a predicted output. More specifically, a machine learning model is a mathematical function that adjusts model parameters by learning from training data to minimize the error between the predicted output and the true label. There are many models in machine learning, such as logistic regression models, decision tree models, support vector machine models, etc. Each model has its applicable data types and problem types. At the same time, there are many commonalities between different models, or there is a hidden path for model evolution. Taking the connectionist perceptron as an example, by increasing the number of hidden layers of the perceptron, we can transform it into a deep neural network. If a kernel function is added to the perceptron, it can be converted into an SVM. this one

The evolution of artificial intelligence in space exploration and human settlement engineering The evolution of artificial intelligence in space exploration and human settlement engineering Apr 29, 2024 pm 03:25 PM

In the 1950s, artificial intelligence (AI) was born. That's when researchers discovered that machines could perform human-like tasks, such as thinking. Later, in the 1960s, the U.S. Department of Defense funded artificial intelligence and established laboratories for further development. Researchers are finding applications for artificial intelligence in many areas, such as space exploration and survival in extreme environments. Space exploration is the study of the universe, which covers the entire universe beyond the earth. Space is classified as an extreme environment because its conditions are different from those on Earth. To survive in space, many factors must be considered and precautions must be taken. Scientists and researchers believe that exploring space and understanding the current state of everything can help understand how the universe works and prepare for potential environmental crises

Implementing Machine Learning Algorithms in C++: Common Challenges and Solutions Implementing Machine Learning Algorithms in C++: Common Challenges and Solutions Jun 03, 2024 pm 01:25 PM

Common challenges faced by machine learning algorithms in C++ include memory management, multi-threading, performance optimization, and maintainability. Solutions include using smart pointers, modern threading libraries, SIMD instructions and third-party libraries, as well as following coding style guidelines and using automation tools. Practical cases show how to use the Eigen library to implement linear regression algorithms, effectively manage memory and use high-performance matrix operations.

Five schools of machine learning you don't know about Five schools of machine learning you don't know about Jun 05, 2024 pm 08:51 PM

Machine learning is an important branch of artificial intelligence that gives computers the ability to learn from data and improve their capabilities without being explicitly programmed. Machine learning has a wide range of applications in various fields, from image recognition and natural language processing to recommendation systems and fraud detection, and it is changing the way we live. There are many different methods and theories in the field of machine learning, among which the five most influential methods are called the "Five Schools of Machine Learning". The five major schools are the symbolic school, the connectionist school, the evolutionary school, the Bayesian school and the analogy school. 1. Symbolism, also known as symbolism, emphasizes the use of symbols for logical reasoning and expression of knowledge. This school of thought believes that learning is a process of reverse deduction, through existing

Explainable AI: Explaining complex AI/ML models Explainable AI: Explaining complex AI/ML models Jun 03, 2024 pm 10:08 PM

Translator | Reviewed by Li Rui | Chonglou Artificial intelligence (AI) and machine learning (ML) models are becoming increasingly complex today, and the output produced by these models is a black box – unable to be explained to stakeholders. Explainable AI (XAI) aims to solve this problem by enabling stakeholders to understand how these models work, ensuring they understand how these models actually make decisions, and ensuring transparency in AI systems, Trust and accountability to address this issue. This article explores various explainable artificial intelligence (XAI) techniques to illustrate their underlying principles. Several reasons why explainable AI is crucial Trust and transparency: For AI systems to be widely accepted and trusted, users need to understand how decisions are made

Is Flash Attention stable? Meta and Harvard found that their model weight deviations fluctuated by orders of magnitude Is Flash Attention stable? Meta and Harvard found that their model weight deviations fluctuated by orders of magnitude May 30, 2024 pm 01:24 PM

MetaFAIR teamed up with Harvard to provide a new research framework for optimizing the data bias generated when large-scale machine learning is performed. It is known that the training of large language models often takes months and uses hundreds or even thousands of GPUs. Taking the LLaMA270B model as an example, its training requires a total of 1,720,320 GPU hours. Training large models presents unique systemic challenges due to the scale and complexity of these workloads. Recently, many institutions have reported instability in the training process when training SOTA generative AI models. They usually appear in the form of loss spikes. For example, Google's PaLM model experienced up to 20 loss spikes during the training process. Numerical bias is the root cause of this training inaccuracy,

See all articles