Yaning1001 commited on
Commit
f6cf676
·
verified ·
1 Parent(s): 64f5718

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. examples/graph/cgscore_experiments/attack_method/attack_dice.py +6 -6
  2. examples/graph/cgscore_experiments/attack_method/attack_meta.py +9 -5
  3. examples/graph/cgscore_experiments/attack_method/attack_minmax.py +6 -4
  4. examples/graph/cgscore_experiments/attack_method/attack_nettack.py +2 -2
  5. examples/graph/cgscore_experiments/attack_method/attack_pgd.py +13 -8
  6. examples/graph/cgscore_experiments/attack_method/attack_random.py +5 -4
  7. examples/graph/cgscore_experiments/attack_method/no_attack.py +1 -1
  8. examples/graph/cgscore_experiments/attacked_adj/Flickr/clean_Flickr_0.0.pt +3 -0
  9. examples/graph/cgscore_experiments/attacked_adj/Flickr/dice_Flickr_0.05.pt +3 -0
  10. examples/graph/cgscore_experiments/attacked_adj/Flickr/dice_Flickr_0.25.pt +1 -1
  11. examples/graph/cgscore_experiments/attacked_adj/Flickr/minmax_Flickr_0.05.pt +3 -0
  12. examples/graph/cgscore_experiments/attacked_adj/Flickr/minmax_Flickr_0.25.pt +3 -0
  13. examples/graph/cgscore_experiments/attacked_adj/Flickr/random_Flickr_0.05.pt +3 -0
  14. examples/graph/cgscore_experiments/attacked_adj/Flickr/random_Flickr_0.25.pt +3 -0
  15. examples/graph/cgscore_experiments/attacked_adj/citeseer/clean_citeseer_0.0.pt +3 -0
  16. examples/graph/cgscore_experiments/attacked_adj/citeseer/dice_citeseer_0.05.pt +3 -0
  17. examples/graph/cgscore_experiments/attacked_adj/citeseer/dice_citeseer_0.25.pt +3 -0
  18. examples/graph/cgscore_experiments/attacked_adj/citeseer/meta_citeseer_0.05.pt +3 -0
  19. examples/graph/cgscore_experiments/attacked_adj/citeseer/meta_citeseer_0.25.pt +3 -0
  20. examples/graph/cgscore_experiments/attacked_adj/citeseer/minmax_citeseer_0.05.pt +3 -0
  21. examples/graph/cgscore_experiments/attacked_adj/citeseer/minmax_citeseer_0.25.pt +3 -0
  22. examples/graph/cgscore_experiments/attacked_adj/citeseer/random_citeseer_0.05.pt +3 -0
  23. examples/graph/cgscore_experiments/attacked_adj/citeseer/random_citeseer_0.25.pt +2 -2
  24. examples/graph/cgscore_experiments/attacked_adj/cora/dice_cora_0.05.pt +3 -0
  25. examples/graph/cgscore_experiments/attacked_adj/cora/dice_cora_0.25.pt +1 -1
  26. examples/graph/cgscore_experiments/attacked_adj/cora/meta_cora_0.05.pt +3 -0
  27. examples/graph/cgscore_experiments/attacked_adj/cora/minmax_cora_0.05.pt +3 -0
  28. examples/graph/cgscore_experiments/attacked_adj/cora/minmax_cora_0.25.pt +1 -1
  29. examples/graph/cgscore_experiments/attacked_adj/cora/random_cora_0.05.pt +3 -0
  30. examples/graph/cgscore_experiments/attacked_adj/cora/random_cora_0.25.pt +1 -1
  31. examples/graph/cgscore_experiments/attacked_adj/polblogs/clean_polblogs_0.0.pt +3 -0
  32. examples/graph/cgscore_experiments/attacked_adj/polblogs/dice_polblogs_0.05.pt +3 -0
  33. examples/graph/cgscore_experiments/attacked_adj/polblogs/dice_polblogs_0.25.pt +3 -0
  34. examples/graph/cgscore_experiments/attacked_adj/polblogs/meta_polblogs_0.05.pt +3 -0
  35. examples/graph/cgscore_experiments/attacked_adj/polblogs/meta_polblogs_0.25.pt +3 -0
  36. examples/graph/cgscore_experiments/attacked_adj/polblogs/minmax_polblogs_0.05.pt +3 -0
  37. examples/graph/cgscore_experiments/attacked_adj/polblogs/minmax_polblogs_0.25.pt +3 -0
  38. examples/graph/cgscore_experiments/attacked_adj/polblogs/random_polblogs_0.05.pt +3 -0
  39. examples/graph/cgscore_experiments/attacked_adj/polblogs/random_polblogs_0.25.pt +3 -0
  40. examples/graph/cgscore_experiments/result/GAT_pubmed_dice_0.25.csv +2 -0
  41. examples/graph/cgscore_experiments/result/GAT_pubmed_minmax_0.25.csv +2 -0
  42. examples/graph/cgscore_experiments/result/GCN_pubmed_clean_0.0.csv +2 -0
  43. examples/graph/cgscore_experiments/result/GCN_pubmed_dice_0.25.csv +2 -0
  44. examples/graph/cgscore_experiments/result/GNNGuard_Flickr_minmax_0.25.csv +2 -0
  45. examples/graph/cgscore_experiments/result/GNNGuard_citeseer_dice_0.25.csv +2 -0
  46. examples/graph/cgscore_experiments/result/GNNGuard_citeseer_minmax_0.25.csv +2 -0
  47. examples/graph/cgscore_experiments/result/GNNGuard_cora_meta_0.25.csv +2 -0
  48. examples/graph/cgscore_experiments/result/GNNGuard_polblogs_clean_0.0.csv +3 -0
  49. examples/graph/cgscore_experiments/result/GNNGuard_polblogs_dice_0.25.csv +3 -0
  50. examples/graph/cgscore_experiments/result/GNNGuard_pubmed_clean_0.0.csv +2 -0
examples/graph/cgscore_experiments/attack_method/attack_dice.py CHANGED
@@ -12,15 +12,15 @@ import argparse
12
 
13
  parser = argparse.ArgumentParser()
14
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
15
- parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
16
- parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
17
  parser.add_argument('--ptb_type', type=str, default='dice', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
18
-
19
 
20
  args = parser.parse_args()
21
  args.cuda = torch.cuda.is_available()
22
  print('cuda: %s' % args.cuda)
23
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
24
 
25
  np.random.seed(args.seed)
26
  torch.manual_seed(args.seed)
@@ -60,8 +60,8 @@ def test(adj):
60
  optimizer = optim.Adam(gcn.parameters(),
61
  lr=0.01, weight_decay=5e-4)
62
 
63
- gcn.fit(features, adj, labels, idx_train) # train without model picking
64
- # gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
65
  output = gcn.output
66
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
67
  acc_test = accuracy(output[idx_test], labels[idx_test])
 
12
 
13
  parser = argparse.ArgumentParser()
14
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
15
+ parser.add_argument('--dataset', type=str, default='cora', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
16
+ parser.add_argument('--ptb_rate', type=float, default=0.05, help='pertubation rate')
17
  parser.add_argument('--ptb_type', type=str, default='dice', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
18
+ parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
19
 
20
  args = parser.parse_args()
21
  args.cuda = torch.cuda.is_available()
22
  print('cuda: %s' % args.cuda)
23
+ device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
24
 
25
  np.random.seed(args.seed)
26
  torch.manual_seed(args.seed)
 
60
  optimizer = optim.Adam(gcn.parameters(),
61
  lr=0.01, weight_decay=5e-4)
62
 
63
+ # gcn.fit(features, adj, labels, idx_train) # train without model picking
64
+ gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
65
  output = gcn.output
66
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
67
  acc_test = accuracy(output[idx_test], labels[idx_test])
examples/graph/cgscore_experiments/attack_method/attack_meta.py CHANGED
@@ -23,16 +23,20 @@ parser.add_argument('--hidden', type=int, default=16,
23
  help='Number of hidden units.')
24
  parser.add_argument('--dropout', type=float, default=0.5,
25
  help='Dropout rate (1 - keep probability).')
26
- parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
27
 
 
28
  parser.add_argument('--ptb_type', type=str, default='meta', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
29
- parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
 
 
 
30
  parser.add_argument('--model', type=str, default='Meta-Self',
31
  choices=['Meta-Self', 'A-Meta-Self', 'Meta-Train', 'A-Meta-Train'], help='model variant')
32
 
33
  args = parser.parse_args()
34
 
35
- device = torch.device("cuda:5" if torch.cuda.is_available() else "cpu")
 
36
  np.random.seed(args.seed)
37
  torch.manual_seed(args.seed)
38
  if device != 'cpu':
@@ -81,8 +85,8 @@ def test(adj):
81
  nclass=labels.max().item() + 1,
82
  dropout=args.dropout, device=device)
83
  gcn = gcn.to(device)
84
- gcn.fit(features, adj, labels, idx_train) # train without model picking
85
- # gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
86
  output = gcn.output.cpu()
87
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
88
  acc_test = accuracy(output[idx_test], labels[idx_test])
 
23
  help='Number of hidden units.')
24
  parser.add_argument('--dropout', type=float, default=0.5,
25
  help='Dropout rate (1 - keep probability).')
 
26
 
27
+ parser.add_argument('--dataset', type=str, default='cora', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
28
  parser.add_argument('--ptb_type', type=str, default='meta', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
29
+ parser.add_argument('--ptb_rate', type=float, default=0.05, help='pertubation rate')
30
+ parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
31
+
32
+
33
  parser.add_argument('--model', type=str, default='Meta-Self',
34
  choices=['Meta-Self', 'A-Meta-Self', 'Meta-Train', 'A-Meta-Train'], help='model variant')
35
 
36
  args = parser.parse_args()
37
 
38
+ device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
39
+
40
  np.random.seed(args.seed)
41
  torch.manual_seed(args.seed)
42
  if device != 'cpu':
 
85
  nclass=labels.max().item() + 1,
86
  dropout=args.dropout, device=device)
87
  gcn = gcn.to(device)
88
+ # gcn.fit(features, adj, labels, idx_train) # train without model picking
89
+ gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
90
  output = gcn.output.cpu()
91
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
92
  acc_test = accuracy(output[idx_test], labels[idx_test])
examples/graph/cgscore_experiments/attack_method/attack_minmax.py CHANGED
@@ -22,14 +22,16 @@ parser.add_argument('--hidden', type=int, default=16,
22
  parser.add_argument('--dropout', type=float, default=0.5,
23
  help='Dropout rate (1 - keep probability).')
24
 
25
- parser.add_argument('--dataset', type=str, default='cora', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
26
  parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
27
  parser.add_argument('--ptb_type', type=str, default='minmax', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
28
  parser.add_argument('--model', type=str, default='min-max', choices=['PGD', 'min-max'], help='model variant')
 
29
 
30
  args = parser.parse_args()
31
 
32
- device = torch.device("cuda:3" if torch.cuda.is_available() else "cpu")
 
33
 
34
  np.random.seed(args.seed)
35
  torch.manual_seed(args.seed)
@@ -70,8 +72,8 @@ def test(adj):
70
  nclass=labels.max().item() + 1,
71
  dropout=args.dropout, device=device)
72
  gcn = gcn.to(device)
73
- gcn.fit(features, adj, labels, idx_train) # train without model picking
74
- # gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
75
  output = gcn.output.cpu()
76
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
77
  acc_test = accuracy(output[idx_test], labels[idx_test])
 
22
  parser.add_argument('--dropout', type=float, default=0.5,
23
  help='Dropout rate (1 - keep probability).')
24
 
25
+ parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
26
  parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
27
  parser.add_argument('--ptb_type', type=str, default='minmax', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
28
  parser.add_argument('--model', type=str, default='min-max', choices=['PGD', 'min-max'], help='model variant')
29
+ parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
30
 
31
  args = parser.parse_args()
32
 
33
+ device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
34
+
35
 
36
  np.random.seed(args.seed)
37
  torch.manual_seed(args.seed)
 
72
  nclass=labels.max().item() + 1,
73
  dropout=args.dropout, device=device)
74
  gcn = gcn.to(device)
75
+ # gcn.fit(features, adj, labels, idx_train) # train without model picking
76
+ gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
77
  output = gcn.output.cpu()
78
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
79
  acc_test = accuracy(output[idx_test], labels[idx_test])
examples/graph/cgscore_experiments/attack_method/attack_nettack.py CHANGED
@@ -13,11 +13,11 @@ parser = argparse.ArgumentParser()
13
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
14
  parser.add_argument('--dataset', type=str, default='citeseer', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed'], help='dataset')
15
 
16
-
17
  args = parser.parse_args()
18
  args.cuda = torch.cuda.is_available()
19
  print('cuda: %s' % args.cuda)
20
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
 
21
 
22
  np.random.seed(args.seed)
23
  torch.manual_seed(args.seed)
 
13
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
14
  parser.add_argument('--dataset', type=str, default='citeseer', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed'], help='dataset')
15
 
 
16
  args = parser.parse_args()
17
  args.cuda = torch.cuda.is_available()
18
  print('cuda: %s' % args.cuda)
19
+ device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
20
+
21
 
22
  np.random.seed(args.seed)
23
  torch.manual_seed(args.seed)
examples/graph/cgscore_experiments/attack_method/attack_pgd.py CHANGED
@@ -22,13 +22,13 @@ parser.add_argument('--hidden', type=int, default=16,
22
  parser.add_argument('--dropout', type=float, default=0.5,
23
  help='Dropout rate (1 - keep probability).')
24
 
25
- parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
26
  parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
27
  parser.add_argument('--ptb_type', type=str, default='pgd', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
28
  parser.add_argument('--model', type=str, default='PGD', choices=['PGD', 'min-max'], help='model variant')
29
-
30
  args = parser.parse_args()
31
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
32
 
33
  np.random.seed(args.seed)
34
  torch.manual_seed(args.seed)
@@ -39,6 +39,12 @@ if device != 'cpu':
39
  data = Dataset(root='/tmp/', name=args.dataset)
40
  adj, features, labels = data.adj, data.features, data.labels
41
 
 
 
 
 
 
 
42
  features = normalize_feature(features.toarray())
43
 
44
  idx_train, idx_val, idx_test = data.idx_train, data.idx_val, data.idx_test
@@ -49,7 +55,6 @@ perturbations = int(args.ptb_rate * (adj.sum()//2))
49
  victim_model = GCN(nfeat=features.shape[1], nclass=labels.max().item()+1, nhid=16,
50
  dropout=0.5, weight_decay=5e-4, device=device)
51
 
52
-
53
  victim_model = victim_model.to(device)
54
  victim_model.fit(features, adj, labels, idx_train)
55
 
@@ -60,16 +65,15 @@ model = model.to(device)
60
 
61
  def test(adj):
62
  ''' test on GCN '''
63
-
64
-
65
  # adj = normalize_adj_tensor(adj)
66
  gcn = GCN(nfeat=features.shape[1],
67
  nhid=args.hidden,
68
  nclass=labels.max().item() + 1,
69
  dropout=args.dropout, device=device)
70
  gcn = gcn.to(device)
71
- gcn.fit(features, adj, labels, idx_train) # train without model picking
72
- # gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
73
  output = gcn.output.cpu()
74
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
75
  acc_test = accuracy(output[idx_test], labels[idx_test])
@@ -99,6 +103,7 @@ def test_gat(adj):
99
 
100
 
101
  def main():
 
102
  model.attack(features, adj, labels, idx_train, perturbations, epochs=args.epochs)
103
  print('=== testing GCN on original(clean) graph ===')
104
  test(adj)
 
22
  parser.add_argument('--dropout', type=float, default=0.5,
23
  help='Dropout rate (1 - keep probability).')
24
 
25
+ parser.add_argument('--dataset', type=str, default='pubmed', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
26
  parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
27
  parser.add_argument('--ptb_type', type=str, default='pgd', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
28
  parser.add_argument('--model', type=str, default='PGD', choices=['PGD', 'min-max'], help='model variant')
29
+ parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
30
  args = parser.parse_args()
31
+ device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
32
 
33
  np.random.seed(args.seed)
34
  torch.manual_seed(args.seed)
 
39
  data = Dataset(root='/tmp/', name=args.dataset)
40
  adj, features, labels = data.adj, data.features, data.labels
41
 
42
+ # print(features)
43
+ # print(adj)
44
+ print(type(features))
45
+ print(type(adj))
46
+ print(type(labels))
47
+
48
  features = normalize_feature(features.toarray())
49
 
50
  idx_train, idx_val, idx_test = data.idx_train, data.idx_val, data.idx_test
 
55
  victim_model = GCN(nfeat=features.shape[1], nclass=labels.max().item()+1, nhid=16,
56
  dropout=0.5, weight_decay=5e-4, device=device)
57
 
 
58
  victim_model = victim_model.to(device)
59
  victim_model.fit(features, adj, labels, idx_train)
60
 
 
65
 
66
  def test(adj):
67
  ''' test on GCN '''
68
+
 
69
  # adj = normalize_adj_tensor(adj)
70
  gcn = GCN(nfeat=features.shape[1],
71
  nhid=args.hidden,
72
  nclass=labels.max().item() + 1,
73
  dropout=args.dropout, device=device)
74
  gcn = gcn.to(device)
75
+ # gcn.fit(features, adj, labels, idx_train) # train without model picking
76
+ gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
77
  output = gcn.output.cpu()
78
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
79
  acc_test = accuracy(output[idx_test], labels[idx_test])
 
103
 
104
 
105
  def main():
106
+
107
  model.attack(features, adj, labels, idx_train, perturbations, epochs=args.epochs)
108
  print('=== testing GCN on original(clean) graph ===')
109
  test(adj)
examples/graph/cgscore_experiments/attack_method/attack_random.py CHANGED
@@ -11,14 +11,15 @@ import os
11
 
12
  parser = argparse.ArgumentParser()
13
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
14
- parser.add_argument('--dataset', type=str, default='cora', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
15
  parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
16
  parser.add_argument('--ptb_type', type=str, default='random', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
 
17
 
18
  args = parser.parse_args()
19
  args.cuda = torch.cuda.is_available()
20
  print('cuda: %s' % args.cuda)
21
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
22
 
23
  np.random.seed(args.seed)
24
  torch.manual_seed(args.seed)
@@ -62,8 +63,8 @@ def test(adj):
62
  optimizer = optim.Adam(gcn.parameters(),
63
  lr=0.01, weight_decay=5e-4)
64
 
65
- gcn.fit(features, adj, labels, idx_train, train_iters=200) # train without model picking
66
- # gcn.fit(features, adj, labels, idx_train, idx_val) # train with validation model picking
67
  output = gcn.output
68
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
69
  acc_test = accuracy(output[idx_test], labels[idx_test])
 
11
 
12
  parser = argparse.ArgumentParser()
13
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
14
+ parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
15
  parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
16
  parser.add_argument('--ptb_type', type=str, default='random', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
17
+ parser.add_argument('--gpu', type=int, default=1, help='GPU device ID (default: 0)')
18
 
19
  args = parser.parse_args()
20
  args.cuda = torch.cuda.is_available()
21
  print('cuda: %s' % args.cuda)
22
+ device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
23
 
24
  np.random.seed(args.seed)
25
  torch.manual_seed(args.seed)
 
63
  optimizer = optim.Adam(gcn.parameters(),
64
  lr=0.01, weight_decay=5e-4)
65
 
66
+ # gcn.fit(features, adj, labels, idx_train, train_iters=200) # train without model picking
67
+ gcn.fit(features, adj, labels, idx_train, idx_val, train_iters=200) # train with validation model picking
68
  output = gcn.output
69
  loss_test = F.nll_loss(output[idx_test], labels[idx_test])
70
  acc_test = accuracy(output[idx_test], labels[idx_test])
examples/graph/cgscore_experiments/attack_method/no_attack.py CHANGED
@@ -11,7 +11,7 @@ import os
11
 
12
  parser = argparse.ArgumentParser()
13
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
14
- parser.add_argument('--dataset', type=str, default='cora', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
15
  parser.add_argument('--ptb_rate', type=float, default=0.00, help='pertubation rate')
16
  parser.add_argument('--ptb_type', type=str, default='clean', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
17
 
 
11
 
12
  parser = argparse.ArgumentParser()
13
  parser.add_argument('--seed', type=int, default=15, help='Random seed.')
14
+ parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
15
  parser.add_argument('--ptb_rate', type=float, default=0.00, help='pertubation rate')
16
  parser.add_argument('--ptb_type', type=str, default='clean', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
17
 
examples/graph/cgscore_experiments/attacked_adj/Flickr/clean_Flickr_0.0.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b51e85e11636d3dd262fd28fd38ca80dc3bf958ae0191eb3969fcce0840891d6
3
+ size 229523721
examples/graph/cgscore_experiments/attacked_adj/Flickr/dice_Flickr_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ddcde81d4d8e543c761255477213661847ed4b8a6b42f38076541c6dc2435a9
3
+ size 229523721
examples/graph/cgscore_experiments/attacked_adj/Flickr/dice_Flickr_0.25.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0ed52214b75ee8b761c57890200430d63e79f3608910e317a1feaacf46ef5f70
3
  size 229523721
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72052a572b6f079d7e0a1f73a200d8e080fc709c0fc80854c23579427fe7845f
3
  size 229523721
examples/graph/cgscore_experiments/attacked_adj/Flickr/minmax_Flickr_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53c1f738951fcbd7c14aea745adfb92b90c80b09f96407c7103a6599ac603fb3
3
+ size 229523731
examples/graph/cgscore_experiments/attacked_adj/Flickr/minmax_Flickr_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36c6660a991758e3c87bb7a6a72b1754663048bcca1f787ff9c17fae94af1416
3
+ size 229523731
examples/graph/cgscore_experiments/attacked_adj/Flickr/random_Flickr_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfefda7cb457ac137938d173f2c9f2eb2286418c56bf1d5075a1631370af8131
3
+ size 229523731
examples/graph/cgscore_experiments/attacked_adj/Flickr/random_Flickr_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a6bf5816a4d03a987a581b7ae87e9a86eb11c7f86cde0826180ea5f1b359de9
3
+ size 229523731
examples/graph/cgscore_experiments/attacked_adj/citeseer/clean_citeseer_0.0.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18298fd88f7ed7c7276862518e11271d676e8508548220fa46829039f69ce94a
3
+ size 17809619
examples/graph/cgscore_experiments/attacked_adj/citeseer/dice_citeseer_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2617b03ef7c992b76ab51627351b63196d387f14905d16483397b99264da51e
3
+ size 17809619
examples/graph/cgscore_experiments/attacked_adj/citeseer/dice_citeseer_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ebf01a6ba0a0e8b5c1d6dc24525d5e6b89f541de0077941ef9fb1e96adf9a7f
3
+ size 17809619
examples/graph/cgscore_experiments/attacked_adj/citeseer/meta_citeseer_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6568a9e6b8609fa32e5f2ce4be50617d8cb7a146e5492cc8584c468a1bd45a5
3
+ size 17809619
examples/graph/cgscore_experiments/attacked_adj/citeseer/meta_citeseer_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6b12c489fbf3754968d7a997fcd9787533a12a0a0a627d986e8122b66d1cf1a
3
+ size 17809619
examples/graph/cgscore_experiments/attacked_adj/citeseer/minmax_citeseer_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1691478483745e430e0e6cb37bd12254df416f7a799c888cb620c374392b81d
3
+ size 17809629
examples/graph/cgscore_experiments/attacked_adj/citeseer/minmax_citeseer_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0bf353082a67aaadc28a5cc95fe4aa18d9fb2be0abfb7f916cd24b7bec6f3ce1
3
+ size 17809629
examples/graph/cgscore_experiments/attacked_adj/citeseer/random_citeseer_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:623c9cf1a424a75ade1afc8e3447a37092d304781256c7bd0a8028a6e6beea40
3
+ size 17809629
examples/graph/cgscore_experiments/attacked_adj/citeseer/random_citeseer_0.25.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d2ad50ab40e983c1a1dfbc8ee6680389f0bde2e7968f99ae68a9ebd10ba48f4b
3
- size 227174
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73eafc6d09d43b43519ff5c5be1d33d2ec5acb1bedeeef487140af6222e69c9f
3
+ size 17809629
examples/graph/cgscore_experiments/attacked_adj/cora/dice_cora_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40482151c9dc07f5e735c920f4dee3161bf3be7e9e34309480d9c668a5a38342
3
+ size 24702079
examples/graph/cgscore_experiments/attacked_adj/cora/dice_cora_0.25.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:bce96164c4b0966c799a3cadfc44d508d05fa1aad74ebf6bf26d6620c68774af
3
  size 24702079
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c5f5ef783b7c6c54e787416858f7549ddeb850df1d32c9759162f6a0f16627d
3
  size 24702079
examples/graph/cgscore_experiments/attacked_adj/cora/meta_cora_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f776908d2d37967f30701b467eb66fa9c1343ef75c3c39f31c89f31b61d09a88
3
+ size 24702079
examples/graph/cgscore_experiments/attacked_adj/cora/minmax_cora_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d4bf8c39fa95661cd14069b13d7af61d000926ad149702bd7dfca2d66821237
3
+ size 24702089
examples/graph/cgscore_experiments/attacked_adj/cora/minmax_cora_0.25.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:671f668695fb010e2089b3a317a239edc17b3741df31604ee5ad4e2452ebdf37
3
  size 24702089
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ad69c827c238afff2a3176d9f04bdcfe0c4668d3fe36d6a4bc8a263800655ad
3
  size 24702089
examples/graph/cgscore_experiments/attacked_adj/cora/random_cora_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11ed525e75f0a2185af4d70134f36981d8e9695c1f436644ac4befede47304b2
3
+ size 24702089
examples/graph/cgscore_experiments/attacked_adj/cora/random_cora_0.25.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5916b397ddc80e9a51821ffedb04221088bbdd3e7f4deca36e2ef66e3ce14cf0
3
  size 24702089
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc8f735c0b4072daf124b176d6063c4bf578b4b2ac1d5a4c8d6c7acda23bf602
3
  size 24702089
examples/graph/cgscore_experiments/attacked_adj/polblogs/clean_polblogs_0.0.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ffcf52226688ad72d600e1082a5efb34a830d2f8b831d25e60f9094ea9035b6
3
+ size 5974355
examples/graph/cgscore_experiments/attacked_adj/polblogs/dice_polblogs_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a43289dde58511b55eec14fb5a402463cc11fda3aeb273e17c28be7ff18589b0
3
+ size 5974355
examples/graph/cgscore_experiments/attacked_adj/polblogs/dice_polblogs_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8d88b44a93aab26964cdf4baac401839efaa474986c145413a498e8ab655d4e
3
+ size 5974355
examples/graph/cgscore_experiments/attacked_adj/polblogs/meta_polblogs_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97fc7a7b434fd4f5aac724f324f6f72037ab64bb4e1a3276eff9b19c8db3bf74
3
+ size 5974355
examples/graph/cgscore_experiments/attacked_adj/polblogs/meta_polblogs_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4876c98765bf5bfb663967acefe53cacb8a7cfbc4cdb2b482700e3550a04ce0
3
+ size 5974355
examples/graph/cgscore_experiments/attacked_adj/polblogs/minmax_polblogs_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5a8e07e6eee1089be2228d6dc0df4dd22c4cb07565058971e0e79e154dcf4fb
3
+ size 5974365
examples/graph/cgscore_experiments/attacked_adj/polblogs/minmax_polblogs_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99c94894e6d682a373f67752be457fe7ff358760108b0b4464cc16178213295a
3
+ size 5974365
examples/graph/cgscore_experiments/attacked_adj/polblogs/random_polblogs_0.05.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e5bf00890edc78b9418a4371c13e186009bd5ae760b989d1864688570d7f855
3
+ size 5974365
examples/graph/cgscore_experiments/attacked_adj/polblogs/random_polblogs_0.25.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4ece2e1a00b043bb514917e15dea8cfad65549bde63a9a2a1560b1b9f70ed68
3
+ size 5974365
examples/graph/cgscore_experiments/result/GAT_pubmed_dice_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ pubmed , dice , 0.25 , 0.7693039178394828
examples/graph/cgscore_experiments/result/GAT_pubmed_minmax_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ pubmed , minmax , 0.25 , 0.600101432737416
examples/graph/cgscore_experiments/result/GCN_pubmed_clean_0.0.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ pubmed , clean , 0.0 , 0.8602130087485736
examples/graph/cgscore_experiments/result/GCN_pubmed_dice_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ pubmed , dice , 0.25 , 0.8168505135032331
examples/graph/cgscore_experiments/result/GNNGuard_Flickr_minmax_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ Flickr , minmax , 0.25 , 0.7496699669966996
examples/graph/cgscore_experiments/result/GNNGuard_citeseer_dice_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ citeseer , dice , 0.25 , 0.6901658767772513
examples/graph/cgscore_experiments/result/GNNGuard_citeseer_minmax_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ citeseer , minmax , 0.25 , 0.6860189573459716
examples/graph/cgscore_experiments/result/GNNGuard_cora_meta_0.25.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ cora , meta , 0.25 , 0.7077464788732395
examples/graph/cgscore_experiments/result/GNNGuard_polblogs_clean_0.0.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ polblogs , clean , 0.0 , 0.4877300613496933
3
+ polblogs , clean , 0.0 , 0.4877300613496933
examples/graph/cgscore_experiments/result/GNNGuard_polblogs_dice_0.25.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ polblogs , dice , 0.25 , 0.4877300613496933
3
+ polblogs , dice , 0.25 , 0.4877300613496933
examples/graph/cgscore_experiments/result/GNNGuard_pubmed_clean_0.0.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ dataset ,ptb_type ,ptb_rate ,accuracy
2
+ pubmed , clean , 0.0 , 0.8444909344490935