Giter Site home page Giter Site logo

graph-neural-networks's Introduction

Packt Conference : Put Generative AI to work on Oct 11-13 (Virtual)

Packt Conference

3 Days, 20+ AI Experts, 25+ Workshops and Power Talks

Code: USD75OFF

Hands-On Graph Neural Networks Using Python

Hands-On Graph Neural Networks Using Python

This is the code repository for Hands-On Graph Neural Networks Using Python, published by Packt.

Practical techniques and architectures for building powerful graph and deep learning apps with PyTorch

What is this book about?

Graph neural networks are a highly effective tool for analyzing data that can be represented as a graph, such as social 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.

This book covers the following exciting features:

  • 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

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders.

The code will look like the following:

DG = nx.DiGraph()
DG.add_edges_from([('A', 'B'), ('A', 'C'), ('B', 'D'), ('B', 'E'), ('C', 'F'), ('C', 'G')])

Following is what you need for this book: 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.

Basic knowledge of Python will help you get more from the examples. With the following software and hardware list you can run all code files present in the book (Chapter 2-14).

Software and Hardware List

You should have a basic understanding of graph theory and machine learning concepts, such as supervised and unsupervised learning, training, and the evaluation of models to maximize your learning experience. Familiarity with deep learning frameworks, such as PyTorch, will also be useful, although not essential, as the book will provide a comprehensive introduction to the mathematical concepts and their implementation.

Software required OS required
Python 3.8.15 Windows, Mac OS X, and Linux (Any)
PyTorch 1.13.1 Windows, Mac OS X, and Linux (Any)
PyTorch Geometric 2.2.0 Windows, Mac OS X, and Linux (Any)

To install Python 3.8.15, you can download the latest version from the official Python website: https://www.python.org/downloads/. We strongly recommend using a virtual environment, such as venv or conda. Optionally, if you want to use a Graphics Processing Unit (GPU) from NVIDIA to accelerate training and inference, you will need to install CUDA and cuDNN:

CUDA is a parallel computing platform and API developed by NVIDIA for general computing on GPUs. To install CUDA, you can follow the instructions on the NVIDIA website: https://developer.nvidia.com/cuda-downloads.

cuDNN is a library developed by NVIDIA, which provides highly optimized GPU implementations of primitives for deep learning algorithms. To install cuDNN, you need to create an account on the NVIDIA website and download the library from the cuDNN download page: https://developer.nvidia.com/cudnn.

You can check out the list of CUDA-enabled GPU products on the NVIDIA website: https://developer.nvidia.com/cuda-gpus. To install PyTorch 1.13.1, you can follow the instructions on the official PyTorch website: https://pytorch.org/. You can choose the installation method that is most appropriate for your system (including CUDA and cuDNN).

To install PyTorch Geometric 2.2.0, you can follow the instructions in the GitHub repository: https://pytorch-eometric.readthedocs.io/en/2.2.0/notes/installation.html. You will need to have PyTorch installed on your system first.

Chapter 11 requires TensorFlow 2.4. To install it, you can follow the instructions on the official TensorFlow website: https://www.tensorflow.org/install. You can choose the installation method that is most appropriate for your system and the version of TensorFlow you want to use.

Chapter 14 requires an older version of PyTorch Geometric (version 2.0.4). It is recommended to create a specific virtual environment for this chapter.

Chapter 15, Chapter 16, and Chapter 17 require a high GPU memory usage. You can lower it by decreasing the size of the training set in the code. Other Python libraries are required in some or most chapters. You can install them using pip install <name==version>, or using another installer depending on your configuration (such as conda).

Here is the complete list of required packages with the corresponding versions:

  • torch==1.13.1+cu117
  • torchvision==0.14.1+cu117
  • torchaudio==0.13.1+cu117
  • pandas==1.5.2
  • gensim==4.3.0
  • torch-scatter==2.1.0+pt113cu117
  • torch-sparse==0.6.16+pt113cu117
  • torch-cluster==1.6.0+pt113cu117
  • torch-spline-conv==1.2.1+pt113cu117
  • torch-geometric==2.2.0
  • networkx==2.8.8
  • matplotlib==3.6.3
  • node2vec==0.4.6
  • seaborn==0.12.2
  • scikit-learn==1.2.0
  • tensorflow-gpu~=2.4
  • deepchem==2.7.1
  • torch-geometric-temporal==0.54.0
  • captum==0.6.0

The complete list of requirements is available on GitHub at https://github.com/PacktPublishing/Hands-On-Graph-Neural-Networks-Using-Python. Alternatively, you can directly import notebooks in Google Colab at https://colab.research.google.com.

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Errata

  • Page 109: Formula of GAT should be image

Related products

Get to Know the Author

Maxime Labonne is a senior applied researcher at J.P. Morgan with a Ph.D. in machine learning and cyber security from the Polytechnic Institute of Paris. During his Ph.D., Maxime worked on developing machine learning algorithms for anomaly detection in computer networks. He then joined the AI Connectivity Lab at Airbus, where he applied his expertise in machine learning to improve the security and performance of computer networks. He then joined J.P. Morgan, where he now develops techniques for solving a variety of challenging problems in finance and other domains. In addition to his research work, Maxime is passionate about sharing his knowledge and experience with others through Twitter (@maximelabonne) and his personal blog.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781804617526

graph-neural-networks's People

Contributors

balvisio avatar davids-packt avatar jubit-packt avatar mlabonne avatar packt-itservice avatar utkarsha-packt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

graph-neural-networks's Issues

What does node2vec expect in .wv method?

Hello,

I;m working through chapter 4. In the prediction of the test set, you use train_mask_str in the book but in your gh code you use train_mask. Depending on which one you use one gets very different results.

if you pass the integer mask you get something that won't go pass 60% accuracy.

y_pred = clf.predict(node2vec.wv[test_mask])
acc = accuracy_score(y_pred, labels[test_mask])
print(f'Node2Vec accuracy = {acc*100:.2f}%')
>>>Node2Vec accuracy = 59.09%

But if i pass the string mask i get what you report both in gh and the book . Which seems really high considering how many samples you pick out in the train and test.

y_pred = clf.predict(node2vec.wv[test_mask_str])
acc = accuracy_score(y_pred, labels[test_mask])
print(f'Node2Vec accuracy = {acc*100:.2f}%')
>>>Node2Vec accuracy = 95.45%

How can one explain this discrepancy?

installing book environment

I can't get to install the exact version of pytorch.
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'pytorch'
note that I found python 3.8.10 not 15

Anyone managed to have the environment working with newer or same version of the libraries?

PeMS-M dataset download

Thanks for this book, but I have problem with PeMS-M dataset in chapter 15. Can you update the download link?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.