Hands-On Graph Neural Networks Using Python

Book description

Design robust graph neural networks with PyTorch Geometric by combining graph theory and neural networks with the latest developments and apps Purchase of the print or Kindle book includes a free PDF eBook

Key Features

  • Implement -of-the-art graph neural architectures in Python
  • Create your own graph datasets from tabular data
  • Build powerful traffic forecasting, recommender systems, and anomaly detection applications

Book Description

Graph neural networks are a highly effective tool for analyzing data that can be represented as a graph, such as networks, chemical compounds, or transportation networks. The past few years have seen an explosion in the use of graph neural networks, with their application ranging from natural language processing and computer vision to recommendation systems and drug discovery.

Hands-On Graph Neural Networks Using Python begins with the fundamentals of graph theory and shows you how to create graph datasets from tabular data. As you advance, you’ll explore major graph neural network architectures and learn essential concepts such as graph convolution, self-attention, link prediction, and heterogeneous graphs. Finally, the book proposes applications to solve real-life problems, enabling you to build a professional portfolio. The code is readily available online and can be easily adapted to other datasets and apps.

By the end of this book, you’ll have learned to create graph datasets, implement graph neural networks using Python and PyTorch Geometric, and apply them to solve real-world problems, along with building and training graph neural network models for node and graph classification, link prediction, and much more.

What you will learn

  • Understand the fundamental concepts of graph neural networks
  • Implement graph neural networks using Python and PyTorch Geometric
  • Classify nodes, graphs, and edges using millions of samples
  • Predict and generate realistic graph topologies
  • Combine heterogeneous sources to improve performance
  • Forecast future events using topological information
  • Apply graph neural networks to solve real-world problems

Who this book is for

This book is for machine learning practitioners and data scientists interested in learning about graph neural networks and their applications, as well as students looking for a comprehensive reference on this rapidly growing field. Whether you’re new to graph neural networks or looking to take your knowledge to the next level, this book has something for you. Basic knowledge of machine learning and Python programming will help you get the most out of this book.

Table of contents

  1. Hands-On Graph Neural Networks Using Python
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share your thoughts
    9. Download a free PDF copy of this book
  6. Part 1: Introduction to Graph Learning
  7. Chapter 1: Getting Started with Graph Learning
    1. Why graphs?
    2. Why graph learning?
    3. Why graph neural networks?
    4. Summary
    5. Further reading
  8. Chapter 2: Graph Theory for Graph Neural Networks
    1. Technical requirements
    2. Introducing graph properties
      1. Directed graphs
      2. Weighted graphs
      3. Connected graphs
      4. Types of graphs
    3. Discovering graph concepts
      1. Fundamental objects
      2. Graph measures
      3. Adjacency matrix representation
    4. Exploring graph algorithms
      1. Breadth-first search
      2. Depth-first search
    5. Summary
  9. Chapter 3: Creating Node Representations with DeepWalk
    1. Technical requirements
    2. Introducing Word2Vec
      1. CBOW versus skip-gram
      2. Creating skip-grams
      3. The skip-gram model
    3. DeepWalk and random walks
    4. Implementing DeepWalk
    5. Summary
    6. Further reading
  10. Part 2: Fundamentals
  11. Chapter 4: Improving Embeddings with Biased Random Walks in Node2Vec
    1. Technical requirements
    2. Introducing Node2Vec
      1. Defining a neighborhood
      2. Introducing biases in random walks
    3. Implementing Node2Vec
    4. Building a movie RecSys
    5. Summary
    6. Further reading
  12. Chapter 5: Including Node Features with Vanilla Neural Networks
    1. Technical requirements
    2. Introducing graph datasets
      1. The Cora dataset
      2. The Facebook Page-Page dataset
    3. Classifying nodes with vanilla neural networks
    4. Classifying nodes with vanilla graph neural networks
    5. Summary
    6. Further reading
  13. Chapter 6: Introducing Graph Convolutional Networks
    1. Technical requirements
    2. Designing the graph convolutional layer
    3. Comparing graph convolutional and graph linear layers
    4. Predicting web traffic with node regression
    5. Summary
    6. Further reading
  14. Chapter 7: Graph Attention Networks
    1. Technical requirements
    2. Introducing the graph attention layer
      1. Linear transformation
      2. Activation function
      3. Softmax normalization
      4. Multi-head attention
      5. Improved graph attention layer
    3. Implementing the graph attention layer in NumPy
    4. Implementing a GAT in PyTorch Geometric
    5. Summary
  15. Part 3: Advanced Techniques
  16. Chapter 8: Scaling Up Graph Neural Networks with GraphSAGE
    1. Technical requirements
    2. Introducing GraphSAGE
      1. Neighbor sampling
      2. Aggregation
    3. Classifying nodes on PubMed
    4. Inductive learning on protein-protein interactions
    5. Summary
    6. Further reading
  17. Chapter 9: Defining Expressiveness for Graph Classification
    1. Technical requirements
    2. Defining expressiveness
    3. Introducing the GIN
    4. Classifying graphs using GIN
      1. Graph classification
      2. Implementing the GIN
    5. Summary
    6. Further reading
  18. Chapter 10: Predicting Links with Graph Neural Networks
    1. Technical requirements
    2. Predicting links with traditional methods
      1. Heuristic techniques
      2. Matrix factorization
    3. Predicting links with node embeddings
      1. Introducing Graph Autoencoders
      2. Introducing VGAEs
      3. Implementing a VGAE
    4. Predicting links with SEAL
      1. Introducing the SEAL framework
      2. Implementing the SEAL framework
    5. Summary
    6. Further reading
  19. Chapter 11: Generating Graphs Using Graph Neural Networks
    1. Technical requirements
    2. Generating graphs with traditional techniques
      1. The Erdős–Rényi model
      2. The small-world model
    3. Generating graphs with graph neural networks
      1. Graph variational autoencoders
      2. Autoregressive models
      3. Generative adversarial networks
    4. Generating molecules with MolGAN
    5. Summary
    6. Further reading
  20. Chapter 12: Learning from Heterogeneous Graphs
    1. Technical requirements
    2. The message passing neural network framework
    3. Introducing heterogeneous graphs
    4. Transforming homogeneous GNNs to heterogeneous GNNs
    5. Implementing a hierarchical self-attention network
    6. Summary
    7. Further reading
  21. Chapter 13: Temporal Graph Neural Networks
    1. Technical requirements
    2. Introducing dynamic graphs
    3. Forecasting web traffic
      1. Introducing EvolveGCN
      2. Implementing EvolveGCN
    4. Predicting cases of COVID-19
      1. Introducing MPNN-LSTM
      2. Implementing MPNN-LSTM
    5. Summary
    6. Further reading
  22. Chapter 14: Explaining Graph Neural Networks
    1. Technical requirements
    2. Introducing explanation techniques
    3. Explaining GNNs with GNNExplainer
      1. Introducing GNNExplainer
      2. Implementing GNNExplainer
    4. Explaining GNNs with Captum
      1. Introducing Captum and integrated gradients
      2. Implementing integrated gradients
    5. Summary
    6. Further reading
  23. Part 4: Applications
  24. Chapter 15: Forecasting Traffic Using A3T-GCN
    1. Technical requirements
    2. Exploring the PeMS-M dataset
    3. Processing the dataset
    4. Implementing the A3T-GCN architecture
    5. Summary
    6. Further reading
  25. Chapter 16: Detecting Anomalies Using Heterogeneous GNNs
    1. Technical requirements
    2. Exploring the CIDDS-001 dataset
    3. Preprocessing the CIDDS-001 dataset
    4. Implementing a heterogeneous GNN
    5. Summary
    6. Further reading
  26. Chapter 17: Building a Recommender System Using LightGCN
    1. Technical requirements
    2. Exploring the Book-Crossing dataset
    3. Preprocessing the Book-Crossing dataset
    4. Implementing the LightGCN architecture
    5. Summary
    6. Further reading
  27. Chapter 18: Unlocking the Potential of Graph Neural Networks for Real-World Applications
  28. Index
    1. Why subscribe?
  29. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share your thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Hands-On Graph Neural Networks Using Python
  • Author(s): Maxime Labonne
  • Release date: April 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781804617526