Skip to main content

Graph Robustness Benchmark

Project description

Graph Robustness Benchmark

Graph Robustness Benchmark (GRB) is a scalable, unified, extendable benchmark for evaluating the adversarial robustness of graph neural networks.

Installation

git clone git@github.com:Stanislas0/grb.git

Usage

Training a GNN model

import torch  # pytorch backend
from grb.dataset import Dataset
from grb.model.torch import GCN
from grb.utils.trainer import Trainer

# Load data
dataset = Dataset(name='grb-cora', mode='easy',
                  feat_norm='arctan')
# Build model
model = GCN(in_features=dataset.num_features,
            out_features=dataset.num_classes,
            hidden_features=[64, 64])
# Training
adam = torch.optim.Adam(model.parameters(), lr=0.01)
trainer = Trainer(dataset=dataset, optimizer=adam,
                  loss=torch.nn.functional.nll_loss)
trainer.train(model=model, n_epoch=200, dropout=0.5,
              train_mode='inductive')

Adversarial attack

from grb.attack.tdgia import TDGIA

# Attack configuration
tdgia = TDGIA(lr=0.01, 
              n_epoch=10,
              n_inject_max=20, 
              n_edge_max=20,
              feat_lim_min=-0.9, 
              feat_lim_max=0.9,
              sequential_step=0.2)
# Apply attack
rst = tdgia.attack(model=model,
                   adj=dataset.adj,
                   features=dataset.features,
                   target_mask=dataset.test_mask)
# Get modified adj and features
adj_attack, features_attack = rst

Requirements

  • scipy==1.5.2
  • numpy==1.19.1
  • torch==1.8.0
  • networkx==2.5
  • pandas~=1.2.3
  • cogdl~=0.3.0.post1
  • scikit-learn~=0.24.1

Contact

If you have any question, please raise an issue or contact qinkai.zheng1028@gmail.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grb-0.0.1.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grb-0.0.1-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

Details for the file grb-0.0.1.tar.gz.

File metadata

  • Download URL: grb-0.0.1.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for grb-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3bdc15d6f937fd4a0ebf23e8dde765f3779b07c1b6a716292da4f871ce25f0a6
MD5 b18f95d5a9388ae0c8d61b4cd544c458
BLAKE2b-256 b925eaa348838abf519eca52c35b007c1d11650645fbed3cd9aab045d52521f3

See more details on using hashes here.

File details

Details for the file grb-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: grb-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 45.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for grb-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d106c361c41bfb19bf6830a1add10ec5737a2517726ffea61681f70ec411d2ea
MD5 c64ec5ac936966798b51b68e485aa56c
BLAKE2b-256 570ed7634499d83ccb678d4749698bfe0b035442c417dfd2b47c5141301b5ef0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page