Graphwar

Latest version: v0.1.0

Safety actively analyzes 624811 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.1.0

The first major release, built upon PyTorch and PyTorch Geometric (PyG).

About GraphWar
**GraphWar** is a graph adversarial learning toolbox based on PyTorch and PyTorch Geometric (PyG). It implements a wide range of adversarial attacks and defense methods focused on graph data. To facilitate the benchmark evaluation on graphs, we also provide a set of implementations on popular Graph Neural Networks (GNNs).


Usages
For more details, please refer to the [documentation](https://graphwar.readthedocs.io/en/latest) and [examples](https://github.com/EdisonLeeeee/GraphWar/blob/master/examples).

How fast can we train and evaluate your own GNN?
Take `GCN` as an example:
python
from graphwar.nn.models import GCN
from graphwar.training import Trainer
from torch_geometric.datasets import Planetoid
dataset = Planetoid(root='.', name='Cora') Any PyG dataset is available!
data = dataset[0]
model = GCN(dataset.num_features, dataset.num_classes)
trainer = Trainer(model, device='cuda:0')
trainer.fit({'data': data, 'mask': data.train_mask})
trainer.evaluate({'data': data, 'mask': data.test_mask})

A simple targeted manipulation attack

python
from graphwar.attack.targeted import RandomAttack
attacker = RandomAttack(data)
attacker.attack(1, num_budgets=3) attacking target node `1` with `3` edges
attacked_data = attacker.data()
edge_flips = attacker.edge_flips()



A simple untargeted (non-targeted) manipulation attack

python
from graphwar.attack.untargeted import RandomAttack
attacker = RandomAttack(data)
attacker.attack(num_budgets=0.05) attacking the graph with 5% edges perturbations
attacked_data = attacker.data()
edge_flips = attacker.edge_flips()


We will continue to develop this project and introduce more state-of-the-art implementations of papers in the field of graph adversarial attacks and defenses.

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.