DSE-MSU / DeepRobust

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

Changing parameters has the same result #112

Closed lizituo0926-bit closed 1 year ago

lizituo0926-bit commented 2 years ago

The same result is found by executing the following instructions: !python /mnt/DeepRobust-master/examples/graph/test_nettack.py --dataset cora --ptb_rate 0.01 !python /mnt/DeepRobust-master/examples/graph/test_nettack.py --dataset cora --ptb_rate 0.03 !python /mnt/DeepRobust-master/examples/graph/test_nettack.py --dataset cora --ptb_rate 0.05

What is the problem and how can I fix it? Looking forward to your reply

result: cuda: True Loading cora dataset... Selecting 1 largest connected components

Starting attack
Attack node with ID 0 using structure and feature perturbations
Attacking the node directly
Performing 5 perturbations
...1/5 perturbations ...

/root/miniconda3/envs/myconda/lib/python3.6/site-packages/numba/core/ir_utils.py:2119: NumbaPendingDeprecationWarning: Encountered the use of a type that is scheduled for deprecation: type 'reflected set' found for argument 'edges_set' of function 'compute_new_a_hat_uv'.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../root/miniconda3/envs/myconda/lib/python3.6/site-packages/deeprobust/graph/targeted_attack/nettack.py", line 501: @jit(nopython=True) def compute_new_a_hat_uv(edge_ixs, node_nb_ixs, edges_set, twohop_ixs, values_before, degs, potential_edges, u): ^

warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc)) Edge perturbation: [ 0 1664]

...2/5 perturbations ...

Edge perturbation: [ 0 1972]

...3/5 perturbations ...

Edge perturbation: [ 0 1084]

...4/5 perturbations ...

Edge perturbation: [ 0 1009]

...5/5 perturbations ...

Edge perturbation: [ 0 839] [(0, 1664), (0, 1972), (0, 1084), (0, 1009), (0, 839)] === testing GCN on original(clean) graph === Target node probs: [0.00865863 0.005858 0.00431516 0.02605057 0.01597398 0.8180082 0.12113561] Overall test set results: accuracy= 0.8380 === testing GCN on perturbed graph === Target node probs: [7.8061840e-04 4.3997480e-04 2.2406746e-03 1.9617765e-03 5.0084112e-04 7.8521296e-03 9.8622411e-01] Overall test set results: accuracy= 0.8370 === [Poisoning] Attacking 40 nodes respectively === 100%|███████████████████████████████████████████| 40/40 [08:46<00:00, 13.16s/it] misclassification rate : 0.925 === [Evasion] Attacking 40 nodes respectively === 100%|███████████████████████████████████████████| 40/40 [07:24<00:00, 11.12s/it] misclassification rate : 0.75

ChandlerBang commented 2 years ago

Hi,

I just noticed that ptb_rate is not used in the main function and the perturbation number is fixed to node degree: https://github.com/DSE-MSU/DeepRobust/blob/e737166fe2fe706c79c2a435e08a3e2853d6b72e/examples/graph/test_nettack.py#L49

Hence, changing ptb_rate does not impact the results and I just removed this parameters.