Giter Site home page Giter Site logo

evansoong517 / messagepassing_for_gnns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anirudhdagar/messagepassing_for_gnns

0.0 0.0 0.0 2.77 MB

Experiments with Message Passing GNNs in C++ and PyTorch.

Shell 0.32% C++ 18.33% Python 20.81% CMake 0.47% Jupyter Notebook 60.08%

messagepassing_for_gnns's Introduction

Message Passing GNNs C++

My experiments with Graph Neural Nets at the scratch level using C++. Graph Convolutional Network (GCN) is one of the most popular GNN architectures and is extremely powerful. Of the popular graph representation learning methods which can be found at https://github.com/dsgiitr/graph_nets, this repo aims to implement GCNs in C++.

GCN C++ Forward Pass

This is a C++ implementation using Eigen for the forward pass of Graph Convolutional Neural Networks . The model doesn't involve any training loops and backpropagation. Pytorch is used to train the GCN model in Python and save the weights learnt after convergence. These saved weights are then imported and used in the C++ implementation of the model for the forward pass on the same dataset.

The GCN architecture and PyTorch implementation are explained in this blog are followed. The network is a 2 layer gcn model.

Training Visualization

karate animation

The predicted outputs from the Python forward pass and C++ forward pass are saved in resources/saved/. As expected, they are almost identical and the similarity between both can be seen quantitatively as well visually with scatter plots in Compare_Predictions.ipynb.

Usage

Step 1

# Clone the repository
git clone https://github.com/AnirudhDagar/MessagePassing_for_GNNs.git

# Download the Karate Club Dataset
bash ./get_karate_club.sh

Step 2

# Train the model and save the weights.
python train.py

Step 3

# Use the CMakeLists.txt to build and run the project for C++ implementation.

# In the source directory
mkdir _build

# Change dir into _build
cd _build

# Build the project
cmake ..
make

OR

# Use a compiler directly to compile the executables.
g++ main.cpp -I eigen -std=c++17

Run at Once

# Run everything at once.
bash run.sh

Requirements

# C++
eigen

# Python
numpy==1.18.1
torch==1.0.0
ConfigArgParse==0.13.0
matplotlib==3.0.1
imageio==2.4.1
celluloid==0.2.0

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

messagepassing_for_gnns's People

Contributors

anirudhdagar avatar dependabot[bot] avatar

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.