Skip to content

Latest commit

 

History

History
137 lines (98 loc) · 9.3 KB

File metadata and controls

137 lines (98 loc) · 9.3 KB
Hands-On Graph Neural Networks Book Cover

Hands-On Graph Neural Networks Using Python

Welcome to the complete code implementation for the book Hands-On Graph Neural Networks Using Python. This repository contains all the code examples from the book, organized into chapters for easy navigation, with each chapter provided in both `.py` and `.ipynb` formats. A `README.md` file accompanies each chapter to guide users through the respective code implementations. This repository is an excellent resource for learners, researchers, and developers interested in exploring and building powerful graph neural networks.

🚀 Quick Overview

  • Author: Maxime Labonne
  • Focus Areas: Graph Neural Networks, PyTorch Geometric, Machine Learning, Node Classification, Graph Embedding, and more
  • Book Reference: Hands-On Graph Neural Networks Using Python
  • Repository Contents: 17 Chapters | .py and .ipynb files | Detailed chapter-wise README.md guides
  • Download and buy the book: www.amazon.com

⭐️ Book Description

Graph Neural Networks (GNNs) have quickly emerged as a cutting-edge technology in deep learning, only a decade after their inception. They are transforming industries worth billions, such as drug discovery, where they played a pivotal role in predicting a novel antibiotic named Halicin. Today, tech companies are exploring their applications in various fields, including recommender systems for food, videos, and romantic partners, as well as fake news detection, chip design, and 3D reconstruction.

In this book, "Graph Neural Networks," we will delve into the core principles of graph theory and learn how to create custom datasets from raw or tabular data. We will explore key graph neural network architectures to grasp essential concepts like graph convolution and self-attention. This foundational knowledge will then be used to understand and implement specialized models tailored for specific tasks such as link prediction and graph classification, as well as various contexts including spatio-temporal data and heterogeneous graphs. Ultimately, we will apply these techniques to solve real-world problems and begin building a professional portfolio.


📂 Repository Structure

Here’s a summary of the chapters implemented in this repository, along with a brief description of each:

Chapter Title Description
01 Getting Started with Graph Learning Learn the basics of graph learning and graph neural networks (GNNs), and understand how to set up your first graph-based model.
02 Graph Theory for Graph Neural Networks Dive into essential graph theory concepts that form the backbone of GNNs and understand their relevance to deep learning models.
03 Creating Node Representations with DeepWalk Learn how to create node embeddings using the DeepWalk algorithm, transforming graph nodes into feature vectors for machine learning.
04 Node2Vec Implement the Node2Vec algorithm to generate improved node embeddings through biased random walks.
05 Vanilla Neural Network Build and understand a basic, fully connected neural network to apply on graph data as a foundation for more complex GNN architectures.
06 Normalizing Features with Graph Convolutional Networks Implement Graph Convolutional Networks (GCNs) to normalize node features and learn how to apply convolutional operations on graph data.
07 Graph Attention Network Introduce attention mechanisms in graph learning through Graph Attention Networks (GAT) for enhanced performance on node classification tasks.
08 Scaling Graph Neural Networks Learn techniques to scale GNNs for large-scale graph data, ensuring efficient training on massive datasets.
09 Graph Classification Implement GNNs for graph classification tasks, using real-world datasets to classify entire graphs rather than individual nodes.
10 Link Prediction Use GNNs to predict links in graphs, helping identify missing or future connections between nodes.
11 Graph Generation Explore generative models for graphs, learning how to create new graphs and complete partial ones using GNNs.
12 Learning from Heterogeneous Graphs Understand how to work with heterogeneous graphs and implement models like Heterogeneous Attention Networks (HAN) to process different types of nodes and edges.
13 Temporal Graph Neural Networks Learn to work with dynamic or temporal graphs and build GNNs that can handle evolving data over time.
14 Explainability Implement GNNExplainer and other tools to interpret GNN models and make sense of the learned representations and predictions.
15 Traffic Forecasting Use GNNs to forecast traffic patterns and other spatio-temporal data, improving decision-making in real-time applications.
16 Anomaly Detection Apply GNNs to detect anomalies in graph data, identifying unusual patterns in networks such as fraud detection or outlier nodes.
17 Recommender Systems Build recommender systems using GNNs to provide personalized recommendations for users, applying GNNs to problems like product, movie, or partner recommendations.

💡 Prerequisites

Before running the code, make sure you have the following tools and libraries installed:

  • Python
  • PyTorch
  • PyTorch Geometric
  • NetworkX
Python Logo PyTorch Logo PyTorch Geometric Logo NetworkX Logo

For each chapter of this repository, there may be additional libraries required. Please refer to the specific README.md files in each chapter directory to find detailed information about the libraries needed and installation instructions.


💡 Running the Code

Each chapter folder contains:

  • A Python script (.py file)
  • A Jupyter Notebook (.ipynb file)
  • A README.md with instructions and explanations for that specific chapter

You can either run the Python scripts directly or execute the Jupyter notebooks interactively:

   # Run the Python script
   python chapter_x/script_name.py

   # Or, open the Jupyter notebook
   jupyter notebook chapter_x/notebook_name.ipynb

✨ Features

  • Learn the fundamentals of graph theory for data science and machine learning

  • Implement state-of-the-art graph neural network architectures

  • Build creative and powerful applications in various fields

  • Real-World Applications: Learn how to apply GNNs to various real-world problems such as molecular graphs, recommendation systems, and social networks.

  • Diverse GNN Architectures: Explore implementations of GCN, GAT, GraphSAGE, VGAE, HAN, and more.

  • Cutting-Edge Techniques: Learn about dynamic graphs, heterogeneous graphs, explainability in GNNs, and large-scale GNNs.


🤝 Contribution

Contributions are welcome! If you find any issues or want to add improvements to the code, feel free to submit a pull request or open an issue.

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/AmazingFeature)

  3. Commit your changes (git commit -m 'Add some AmazingFeature')

  4. Push to the branch (git push origin feature/AmazingFeature)

  5. Open a pull request


📝 License

This repository is licensed under the Apache License 2.0. See the LICENSE file for more details.