DSE-MSU / DeepRobust

A pytorch adversarial library for attack and defense methods on images and graphs
MIT License
957 stars 191 forks source link

How targeted_attack attack a subset of nodes? #134

Open Xxxxxsun opened 1 year ago

Xxxxxsun commented 1 year ago

Hello! I have encountered a problem while using DeepRobust (Nettack) to attack the Cora dataset. I have noticed that in the Nettack API, the target_node argument should be an integer. How can I modify this API to attack a list of nodes instead? target_node = 0 model = Nettack(surrogate, nnodes=adj.shape[0], attack_structure=True, attack_features=True, device='cpu').to('cpu') model.attack(features, adj, labels, target_node, n_perturbations=5)

ChandlerBang commented 1 year ago

Hey, you may take a look here: test_nettack.py. It shows how to perform targeted attack on target nodes.

Xxxxxsun commented 1 year ago

Thank you so much for your quick response!!!