Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- deeprobust/graph/defense/gcn_guard.py +3 -3
- deeprobust/graph/defense/gcn_preprocess.py +102 -30
- deeprobust/graph/global_attack/base_attack.py +1 -0
- deeprobust/graph/global_attack/topology_attack.py +1 -1
- examples/graph/cgscore_experiments/defense_method/GAT.py +28 -6
- examples/graph/cgscore_experiments/defense_method/GCN.py +23 -5
- examples/graph/cgscore_experiments/defense_method/GCNJaccard.py +29 -9
- examples/graph/cgscore_experiments/defense_method/GCNSVD.py +32 -7
- examples/graph/cgscore_experiments/defense_method/GNNGuard.py +25 -6
- examples/graph/cgscore_experiments/defense_method/ProGNN.py +27 -4
- examples/graph/cgscore_experiments/defense_method/RGCN.py +26 -6
- examples/graph/cgscore_experiments/result/GAT_Flickr_clean_0.0.csv +3 -0
- examples/graph/cgscore_experiments/result/GAT_Flickr_dice_0.25.csv +3 -0
- examples/graph/cgscore_experiments/result/GAT_Flickr_minmax_0.25.csv +3 -0
- examples/graph/cgscore_experiments/result/GAT_pubmed_clean_0.0.csv +2 -0
- examples/graph/cgscore_experiments/result/GCN_Flickr_clean_0.0.csv +3 -0
- examples/graph/cgscore_experiments/result/GCN_Flickr_dice_0.25.csv +6 -0
- examples/graph/cgscore_experiments/result/GCN_Flickr_minmax_0.25.csv +4 -0
- examples/graph/cgscore_experiments/result/GCN_pubmed_minmax_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/GNNGuard_Flickr_clean_0.0.csv +2 -0
- examples/graph/cgscore_experiments/result/GNNGuard_Flickr_dice_0.25.csv +3 -0
- examples/graph/cgscore_experiments/result/GNNGuard_citeseer_clean_0.0.csv +2 -0
- examples/graph/cgscore_experiments/result/GNNGuard_citeseer_meta_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/GNNGuard_cora_clean_0.0.csv +2 -0
- examples/graph/cgscore_experiments/result/GNNGuard_cora_dice_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/GNNGuard_cora_minmax_0.25.csv +3 -0
- examples/graph/cgscore_experiments/result/GNNGuard_polblogs_meta_0.25.csv +3 -0
- examples/graph/cgscore_experiments/result/GNNGuard_polblogs_minmax_0.25.csv +3 -0
- examples/graph/cgscore_experiments/result/GNNGuard_pubmed_dice_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/Jaccard_Flickr_clean_0.0.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_Flickr_dice_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/Jaccard_Flickr_minmax_0.25.csv +6 -0
- examples/graph/cgscore_experiments/result/Jaccard_citeseer_clean_0.0.csv +35 -0
- examples/graph/cgscore_experiments/result/Jaccard_citeseer_meta_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_citeseer_minmax_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_citeseer_random_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_cora_minmax_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_cora_random_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_polblogs_clean_0.0.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_polblogs_dice_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_polblogs_meta_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/Jaccard_pubmed_minmax_0.25.csv +15 -0
- examples/graph/cgscore_experiments/result/ProGNN_Flickr_clean_0.0.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_Flickr_dice_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_Flickr_minmax_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_citeseer_dice_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_citeseer_minmax_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_cora_minmax_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_polblogs_dice_0.25.csv +2 -0
- examples/graph/cgscore_experiments/result/ProGNN_polblogs_minmax_0.25.csv +2 -0
deeprobust/graph/defense/gcn_guard.py
CHANGED
@@ -25,7 +25,7 @@ from scipy.sparse import lil_matrix
|
|
25 |
|
26 |
class GCNGuard(nn.Module):
|
27 |
|
28 |
-
def __init__(self, nfeat, nhid, nclass, dropout=0.5, lr=0.01, drop=
|
29 |
with_bias=True, device=None):
|
30 |
|
31 |
super(GCNGuard, self).__init__()
|
@@ -102,7 +102,7 @@ class GCNGuard(nn.Module):
|
|
102 |
def forward(self, x, adj):
|
103 |
"""we don't change the edge_index, just update the edge_weight;
|
104 |
some edge_weight are regarded as removed if it equals to zero"""
|
105 |
-
x = x.to_dense()
|
106 |
|
107 |
"""GCN and GAT"""
|
108 |
if self.attention:
|
@@ -189,7 +189,7 @@ class GCNGuard(nn.Module):
|
|
189 |
if self.drop:
|
190 |
character = np.vstack((att_dense_norm[row, col].A1,
|
191 |
att_dense_norm[col, row].A1))
|
192 |
-
character = torch.from_numpy(character.T)
|
193 |
drop_score = self.drop_learn_1(character)
|
194 |
drop_score = torch.sigmoid(drop_score) # do not use softmax since we only have one element
|
195 |
mm = torch.nn.Threshold(0.5, 0)
|
|
|
25 |
|
26 |
class GCNGuard(nn.Module):
|
27 |
|
28 |
+
def __init__(self, nfeat, nhid, nclass, dropout=0.5, lr=0.01, drop=True, weight_decay=5e-4, with_relu=True,
|
29 |
with_bias=True, device=None):
|
30 |
|
31 |
super(GCNGuard, self).__init__()
|
|
|
102 |
def forward(self, x, adj):
|
103 |
"""we don't change the edge_index, just update the edge_weight;
|
104 |
some edge_weight are regarded as removed if it equals to zero"""
|
105 |
+
x = x.to_dense()
|
106 |
|
107 |
"""GCN and GAT"""
|
108 |
if self.attention:
|
|
|
189 |
if self.drop:
|
190 |
character = np.vstack((att_dense_norm[row, col].A1,
|
191 |
att_dense_norm[col, row].A1))
|
192 |
+
character = torch.from_numpy(character.T).to(self.device)
|
193 |
drop_score = self.drop_learn_1(character)
|
194 |
drop_score = torch.sigmoid(drop_score) # do not use softmax since we only have one element
|
195 |
mm = torch.nn.Threshold(0.5, 0)
|
deeprobust/graph/defense/gcn_preprocess.py
CHANGED
@@ -6,6 +6,7 @@ from torch.nn.parameter import Parameter
|
|
6 |
from torch.nn.modules.module import Module
|
7 |
from deeprobust.graph import utils
|
8 |
from deeprobust.graph.defense import GCN
|
|
|
9 |
from tqdm import tqdm
|
10 |
import scipy.sparse as sp
|
11 |
import numpy as np
|
@@ -104,37 +105,86 @@ class GCNSVD(GCN):
|
|
104 |
self.labels = labels
|
105 |
super().fit(features, modified_adj, labels, idx_train, idx_val, train_iters=train_iters, initialize=initialize, verbose=verbose)
|
106 |
|
107 |
-
def truncatedSVD(self, data, k=50):
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
-
return U @ diag_S @ V
|
138 |
|
139 |
def predict(self, features=None, adj=None):
|
140 |
"""By default, the inputs should be unnormalized adjacency
|
@@ -276,6 +326,7 @@ class GCNJaccard(GCN):
|
|
276 |
removed_cnt = dropedge_dis(adj_triu.data, adj_triu.indptr, adj_triu.indices, features, threshold=self.threshold)
|
277 |
else:
|
278 |
if self.binary_feature:
|
|
|
279 |
removed_cnt = dropedge_jaccard(adj_triu.data, adj_triu.indptr, adj_triu.indices, features, threshold=self.threshold)
|
280 |
else:
|
281 |
removed_cnt = dropedge_cosine(adj_triu.data, adj_triu.indptr, adj_triu.indices, features, threshold=self.threshold)
|
@@ -378,6 +429,22 @@ def __dropedge_jaccard(A, iA, jA, features, threshold):
|
|
378 |
removed_cnt += 1
|
379 |
return removed_cnt
|
380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
@njit
|
382 |
def dropedge_jaccard(A, iA, jA, features, threshold):
|
383 |
removed_cnt = 0
|
@@ -388,7 +455,12 @@ def dropedge_jaccard(A, iA, jA, features, threshold):
|
|
388 |
n2 = jA[i]
|
389 |
a, b = features[n1], features[n2]
|
390 |
intersection = np.count_nonzero(a*b)
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
if J < threshold:
|
394 |
A[i] = 0
|
|
|
6 |
from torch.nn.modules.module import Module
|
7 |
from deeprobust.graph import utils
|
8 |
from deeprobust.graph.defense import GCN
|
9 |
+
from sklearn.utils.extmath import randomized_svd
|
10 |
from tqdm import tqdm
|
11 |
import scipy.sparse as sp
|
12 |
import numpy as np
|
|
|
105 |
self.labels = labels
|
106 |
super().fit(features, modified_adj, labels, idx_train, idx_val, train_iters=train_iters, initialize=initialize, verbose=verbose)
|
107 |
|
108 |
+
# def truncatedSVD(self, data, k=50):
|
109 |
+
# """Truncated SVD on input data.
|
110 |
+
|
111 |
+
# Parameters
|
112 |
+
# ----------
|
113 |
+
# data :
|
114 |
+
# input matrix to be decomposed
|
115 |
+
# k : int
|
116 |
+
# number of singular values and vectors to compute.
|
117 |
+
|
118 |
+
# Returns
|
119 |
+
# -------
|
120 |
+
# numpy.array
|
121 |
+
# reconstructed matrix.
|
122 |
+
# """
|
123 |
+
# print('=== GCN-SVD: rank={} ==='.format(k))
|
124 |
+
# print("stage1")
|
125 |
+
# if sp.issparse(data):
|
126 |
+
# data = data.asfptype()
|
127 |
+
# U, S, V = sp.linalg.svds(data, k=k)
|
128 |
+
# print("rank_after = {}".format(len(S.nonzero()[0])))
|
129 |
+
# diag_S = np.diag(S)
|
130 |
+
# else:
|
131 |
+
# U, S, V = np.linalg.svd(data)
|
132 |
+
# U = U[:, :k]
|
133 |
+
# S = S[:k]
|
134 |
+
# V = V[:k, :]
|
135 |
+
# print("rank_before = {}".format(len(S.nonzero()[0])))
|
136 |
+
# diag_S = np.diag(S)
|
137 |
+
# print("rank_after = {}".format(len(diag_S.nonzero()[0])))
|
138 |
+
|
139 |
+
# return U @ diag_S @ V
|
140 |
|
141 |
+
def truncatedSVD(self, data, k=50):
|
142 |
+
"""Fast truncated SVD using randomized algorithm"""
|
143 |
+
print(f'=== Fast SVD: rank={k} ===')
|
144 |
+
|
145 |
+
# Convert torch Tensor to NumPy
|
146 |
+
if isinstance(data, torch.Tensor):
|
147 |
+
data = data.detach().cpu().numpy()
|
148 |
+
|
149 |
+
U, S, Vt = randomized_svd(data, n_components=k, n_iter=10, random_state=None)
|
150 |
+
print("rank_after =", np.count_nonzero(S))
|
151 |
+
diag_S = np.diag(S)
|
152 |
+
return U @ diag_S @ Vt
|
153 |
+
|
154 |
+
# def truncatedSVD(self, data, k=50):
|
155 |
+
|
156 |
+
# """Truncated SVD on input data using GPU (torch.linalg.svd), returning numpy array."""
|
157 |
+
# print('=== GCN-SVD (GPU): rank={} ==='.format(k))
|
158 |
+
# # 转换为 dense 并放到 GPU
|
159 |
+
# if sp.issparse(data):
|
160 |
+
# print("[Info] Converting sparse matrix to dense (may be memory-intensive).")
|
161 |
+
# data = torch.from_numpy(data.toarray()).float().to(self.device)
|
162 |
+
# elif isinstance(data, np.ndarray):
|
163 |
+
# data = torch.from_numpy(data).float().to(self.device)
|
164 |
+
# elif isinstance(data, torch.Tensor):
|
165 |
+
# data = data.float().to(self.device)
|
166 |
+
# else:
|
167 |
+
# raise TypeError("Unsupported data type for SVD.")
|
168 |
+
|
169 |
+
# print("stage1")
|
170 |
+
# #
|
171 |
+
# U, S, Vh = torch.linalg.svd(data, full_matrices=False)
|
172 |
+
|
173 |
+
# print("stage2")
|
174 |
+
# #
|
175 |
+
# U_k = U[:, :k]
|
176 |
+
# S_k = S[:k]
|
177 |
+
# V_k = Vh[:k, :]
|
178 |
+
|
179 |
+
# print(f"Singular values used (non-zero count): {(S_k != 0).sum().item()} / {len(S_k)}")
|
180 |
+
|
181 |
+
# # 还原矩阵:U * S * V
|
182 |
+
# diag_S = torch.diag(S_k)
|
183 |
+
# reconstructed = U_k @ diag_S @ V_k
|
184 |
+
|
185 |
+
# # 返回 numpy 类型(保持一致)
|
186 |
+
# return reconstructed.detach().cpu().numpy()
|
187 |
|
|
|
188 |
|
189 |
def predict(self, features=None, adj=None):
|
190 |
"""By default, the inputs should be unnormalized adjacency
|
|
|
326 |
removed_cnt = dropedge_dis(adj_triu.data, adj_triu.indptr, adj_triu.indices, features, threshold=self.threshold)
|
327 |
else:
|
328 |
if self.binary_feature:
|
329 |
+
print("self.binary_feature", self.binary_feature)
|
330 |
removed_cnt = dropedge_jaccard(adj_triu.data, adj_triu.indptr, adj_triu.indices, features, threshold=self.threshold)
|
331 |
else:
|
332 |
removed_cnt = dropedge_cosine(adj_triu.data, adj_triu.indptr, adj_triu.indices, features, threshold=self.threshold)
|
|
|
429 |
removed_cnt += 1
|
430 |
return removed_cnt
|
431 |
|
432 |
+
# @njit
|
433 |
+
# def dropedge_jaccard(A, iA, jA, features, threshold):
|
434 |
+
# removed_cnt = 0
|
435 |
+
# for row in range(len(iA)-1):
|
436 |
+
# for i in range(iA[row], iA[row+1]):
|
437 |
+
# # print(row, jA[i], A[i])
|
438 |
+
# n1 = row
|
439 |
+
# n2 = jA[i]
|
440 |
+
# a, b = features[n1], features[n2]
|
441 |
+
# intersection = np.count_nonzero(a*b)
|
442 |
+
# J = intersection * 1.0 / (np.count_nonzero(a) + np.count_nonzero(b) - intersection)
|
443 |
+
# if J < threshold:
|
444 |
+
# A[i] = 0
|
445 |
+
# # A[n2, n1] = 0
|
446 |
+
# removed_cnt += 1
|
447 |
+
# return removed_cnt
|
448 |
@njit
|
449 |
def dropedge_jaccard(A, iA, jA, features, threshold):
|
450 |
removed_cnt = 0
|
|
|
455 |
n2 = jA[i]
|
456 |
a, b = features[n1], features[n2]
|
457 |
intersection = np.count_nonzero(a*b)
|
458 |
+
union = np.count_nonzero(a) + np.count_nonzero(b) - intersection
|
459 |
+
if union == 0:
|
460 |
+
print("Running safe dropedge_jaccard")
|
461 |
+
J = 0
|
462 |
+
else:
|
463 |
+
J = intersection * 1.0 / union
|
464 |
|
465 |
if J < threshold:
|
466 |
A[i] = 0
|
deeprobust/graph/global_attack/base_attack.py
CHANGED
@@ -71,6 +71,7 @@ class BaseAttack(Module):
|
|
71 |
assert torch.abs(adj - adj.t()).sum() == 0, "Input graph is not symmetric"
|
72 |
assert adj.max() == 1, "Max value should be 1!"
|
73 |
assert adj.min() == 0, "Min value should be 0!"
|
|
|
74 |
diag = adj.diag()
|
75 |
assert diag.max() == 0, "Diagonal should be 0!"
|
76 |
assert diag.min() == 0, "Diagonal should be 0!"
|
|
|
71 |
assert torch.abs(adj - adj.t()).sum() == 0, "Input graph is not symmetric"
|
72 |
assert adj.max() == 1, "Max value should be 1!"
|
73 |
assert adj.min() == 0, "Min value should be 0!"
|
74 |
+
adj.fill_diagonal_(0)
|
75 |
diag = adj.diag()
|
76 |
assert diag.max() == 0, "Diagonal should be 0!"
|
77 |
assert diag.min() == 0, "Diagonal should be 0!"
|
deeprobust/graph/global_attack/topology_attack.py
CHANGED
@@ -79,7 +79,7 @@ class PGDAttack(BaseAttack):
|
|
79 |
|
80 |
self.complementary = None
|
81 |
|
82 |
-
def attack(self, ori_features, ori_adj, labels, idx_train, n_perturbations, epochs=
|
83 |
"""Generate perturbations on the input graph.
|
84 |
|
85 |
Parameters
|
|
|
79 |
|
80 |
self.complementary = None
|
81 |
|
82 |
+
def attack(self, ori_features, ori_adj, labels, idx_train, n_perturbations, epochs=50, **kwargs):
|
83 |
"""Generate perturbations on the input graph.
|
84 |
|
85 |
Parameters
|
examples/graph/cgscore_experiments/defense_method/GAT.py
CHANGED
@@ -6,19 +6,23 @@ from deeprobust.graph.defense import GCNJaccard, GCN, GAT
|
|
6 |
from deeprobust.graph.utils import *
|
7 |
from deeprobust.graph.data import Dataset, PrePtbDataset, Dpr2Pyg
|
8 |
import argparse
|
|
|
|
|
9 |
|
10 |
parser = argparse.ArgumentParser()
|
11 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
12 |
-
parser.add_argument('--dataset', type=str, default='
|
13 |
-
parser.add_argument('--ptb_rate', type=float, default=0.
|
14 |
-
parser.add_argument('--ptb_type', type=str, default='
|
15 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
16 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
|
|
17 |
|
18 |
args = parser.parse_args()
|
19 |
args.cuda = torch.cuda.is_available()
|
20 |
print('cuda: %s' % args.cuda)
|
21 |
-
device = torch.device("cuda:
|
|
|
22 |
|
23 |
# make sure you use the same data splits as you generated attacks
|
24 |
np.random.seed(args.seed)
|
@@ -57,5 +61,23 @@ print('=== train on clean graph ===')
|
|
57 |
|
58 |
pyg_data = Dpr2Pyg(data)
|
59 |
pyg_data.update_edge_index(perturbed_adj) # inplace operation
|
60 |
-
gat.fit(pyg_data, train_iters=
|
61 |
-
gat.test()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
from deeprobust.graph.utils import *
|
7 |
from deeprobust.graph.data import Dataset, PrePtbDataset, Dpr2Pyg
|
8 |
import argparse
|
9 |
+
import csv
|
10 |
+
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='pubmed', 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='dice', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
17 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
18 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
19 |
+
parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
|
20 |
|
21 |
args = parser.parse_args()
|
22 |
args.cuda = torch.cuda.is_available()
|
23 |
print('cuda: %s' % args.cuda)
|
24 |
+
device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
|
25 |
+
|
26 |
|
27 |
# make sure you use the same data splits as you generated attacks
|
28 |
np.random.seed(args.seed)
|
|
|
61 |
|
62 |
pyg_data = Dpr2Pyg(data)
|
63 |
pyg_data.update_edge_index(perturbed_adj) # inplace operation
|
64 |
+
gat.fit(pyg_data, train_iters=500, verbose=True) # train with earlystopping
|
65 |
+
acc = gat.test()
|
66 |
+
print("acc:", acc)
|
67 |
+
|
68 |
+
csv_dir = "../result"
|
69 |
+
os.makedirs(csv_dir, exist_ok=True)
|
70 |
+
|
71 |
+
csv_filename = os.path.join(csv_dir, f"GAT_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
72 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {acc}"]
|
73 |
+
|
74 |
+
try:
|
75 |
+
file_exists = os.path.isfile(csv_filename)
|
76 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
77 |
+
writer = csv.writer(csvfile)
|
78 |
+
if not file_exists:
|
79 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "accuracy"])
|
80 |
+
writer.writerow(row)
|
81 |
+
except Exception as e:
|
82 |
+
print(f"[Error] Failed to write CSV: {e}")
|
83 |
+
|
examples/graph/cgscore_experiments/defense_method/GCN.py
CHANGED
@@ -5,19 +5,22 @@ from deeprobust.graph.defense import GCNJaccard, GCN
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
|
|
|
|
8 |
|
9 |
parser = argparse.ArgumentParser()
|
10 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
11 |
-
parser.add_argument('--dataset', type=str, default='
|
12 |
-
parser.add_argument('--ptb_rate', type=float, default=0.
|
13 |
-
parser.add_argument('--ptb_type', type=str, default='
|
14 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
15 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
|
|
16 |
|
17 |
args = parser.parse_args()
|
18 |
args.cuda = torch.cuda.is_available()
|
19 |
print('cuda: %s' % args.cuda)
|
20 |
-
device = torch.device("cuda:
|
21 |
|
22 |
# make sure you use the same data splits as you generated attacks
|
23 |
np.random.seed(args.seed)
|
@@ -63,7 +66,22 @@ def test(adj):
|
|
63 |
|
64 |
def main():
|
65 |
|
66 |
-
test(perturbed_adj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
# # if you want to save the modified adj/features, uncomment the code below
|
69 |
# model.save_adj(root='./', name=f'mod_adj')
|
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
8 |
+
import os
|
9 |
+
import csv
|
10 |
|
11 |
parser = argparse.ArgumentParser()
|
12 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
13 |
+
parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
|
14 |
+
parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
|
15 |
+
parser.add_argument('--ptb_type', type=str, default='minmax', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
16 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
17 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
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 |
# make sure you use the same data splits as you generated attacks
|
26 |
np.random.seed(args.seed)
|
|
|
66 |
|
67 |
def main():
|
68 |
|
69 |
+
acc = test(perturbed_adj)
|
70 |
+
csv_dir = "../result"
|
71 |
+
os.makedirs(csv_dir, exist_ok=True)
|
72 |
+
|
73 |
+
csv_filename = os.path.join(csv_dir, f"GCN_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
74 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {acc}"]
|
75 |
+
|
76 |
+
try:
|
77 |
+
file_exists = os.path.isfile(csv_filename)
|
78 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
79 |
+
writer = csv.writer(csvfile)
|
80 |
+
if not file_exists:
|
81 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "accuracy"])
|
82 |
+
writer.writerow(row)
|
83 |
+
except Exception as e:
|
84 |
+
print(f"[Error] Failed to write CSV: {e}")
|
85 |
|
86 |
# # if you want to save the modified adj/features, uncomment the code below
|
87 |
# model.save_adj(root='./', name=f'mod_adj')
|
examples/graph/cgscore_experiments/defense_method/GCNJaccard.py
CHANGED
@@ -4,21 +4,24 @@ import torch.nn.functional as F
|
|
4 |
from deeprobust.graph.defense import GCNJaccard, GCN
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
|
|
7 |
import argparse
|
|
|
8 |
|
9 |
parser = argparse.ArgumentParser()
|
10 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
11 |
-
parser.add_argument('--dataset', type=str, default='
|
12 |
-
parser.add_argument('--ptb_rate', type=float, default=0.
|
13 |
-
parser.add_argument('--ptb_type', type=str, default='
|
14 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
15 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
16 |
parser.add_argument('--threshold', type=float, default=0.1, help='jaccard coeficient')
|
|
|
17 |
|
18 |
args = parser.parse_args()
|
19 |
args.cuda = torch.cuda.is_available()
|
20 |
print('cuda: %s' % args.cuda)
|
21 |
-
device = torch.device("cuda:
|
22 |
|
23 |
# make sure you use the same data splits as you generated attacks
|
24 |
np.random.seed(args.seed)
|
@@ -54,15 +57,32 @@ def test_jaccard(adj):
|
|
54 |
gcn = gcn.to(device)
|
55 |
gcn.fit(features, adj, labels, idx_train, idx_val, threshold=args.threshold)
|
56 |
gcn.eval()
|
57 |
-
gcn.test(idx_test)
|
|
|
58 |
|
59 |
|
60 |
def main():
|
61 |
|
62 |
-
test_jaccard(perturbed_adj)
|
63 |
-
|
64 |
-
|
65 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
if __name__ == '__main__':
|
68 |
main()
|
|
|
4 |
from deeprobust.graph.defense import GCNJaccard, GCN
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
+
import csv
|
8 |
import argparse
|
9 |
+
import os
|
10 |
|
11 |
parser = argparse.ArgumentParser()
|
12 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
13 |
+
parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
|
14 |
+
parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
|
15 |
+
parser.add_argument('--ptb_type', type=str, default='dice', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
16 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
17 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
18 |
parser.add_argument('--threshold', type=float, default=0.1, help='jaccard coeficient')
|
19 |
+
parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
|
20 |
|
21 |
args = parser.parse_args()
|
22 |
args.cuda = torch.cuda.is_available()
|
23 |
print('cuda: %s' % args.cuda)
|
24 |
+
device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
|
25 |
|
26 |
# make sure you use the same data splits as you generated attacks
|
27 |
np.random.seed(args.seed)
|
|
|
57 |
gcn = gcn.to(device)
|
58 |
gcn.fit(features, adj, labels, idx_train, idx_val, threshold=args.threshold)
|
59 |
gcn.eval()
|
60 |
+
test_acc = gcn.test(idx_test)
|
61 |
+
return test_acc
|
62 |
|
63 |
|
64 |
def main():
|
65 |
|
66 |
+
acc = test_jaccard(perturbed_adj)
|
67 |
+
|
68 |
+
print(acc)
|
69 |
+
# record result
|
70 |
+
csv_dir = "../result"
|
71 |
+
os.makedirs(csv_dir, exist_ok=True) # 自动创建目录(如果不存在)
|
72 |
+
|
73 |
+
csv_filename = os.path.join(csv_dir, f"Jaccard_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
74 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {args.threshold} ", f" {acc}"]
|
75 |
+
|
76 |
+
# 写入 CSV 文件
|
77 |
+
try:
|
78 |
+
file_exists = os.path.isfile(csv_filename)
|
79 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
80 |
+
writer = csv.writer(csvfile)
|
81 |
+
if not file_exists:
|
82 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "threshold ", "accuracy"])
|
83 |
+
writer.writerow(row)
|
84 |
+
except Exception as e:
|
85 |
+
print(f"[Error] Failed to write CSV: {e}")
|
86 |
|
87 |
if __name__ == '__main__':
|
88 |
main()
|
examples/graph/cgscore_experiments/defense_method/GCNSVD.py
CHANGED
@@ -5,20 +5,25 @@ from deeprobust.graph.defense import GCNJaccard, GCN, GCNSVD
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
|
|
|
|
8 |
|
9 |
parser = argparse.ArgumentParser()
|
10 |
-
parser.add_argument('--seed', type=int, default=
|
11 |
-
parser.add_argument('--dataset', type=str, default='
|
12 |
-
parser.add_argument('--ptb_rate', type=float, default=0.
|
13 |
-
parser.add_argument('--ptb_type', type=str, default='
|
14 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
15 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
16 |
parser.add_argument('--k', type=int, default=50, help='Truncated Components.')
|
|
|
17 |
|
18 |
args = parser.parse_args()
|
19 |
args.cuda = torch.cuda.is_available()
|
20 |
print('cuda: %s' % args.cuda)
|
21 |
-
device = torch.device("cuda:
|
|
|
|
|
22 |
|
23 |
# make sure you use the same data splits as you generated attacks
|
24 |
np.random.seed(args.seed)
|
@@ -49,12 +54,32 @@ def test_svd(adj):
|
|
49 |
gcn = gcn.to(device)
|
50 |
gcn.fit(features, perturbed_adj, labels, idx_train, idx_val, k=args.k, verbose=True)
|
51 |
gcn.eval()
|
52 |
-
gcn.test(idx_test)
|
|
|
53 |
|
54 |
|
55 |
def main():
|
56 |
|
57 |
-
test_svd(perturbed_adj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
# # if you want to save the modified adj/features, uncomment the code below
|
59 |
# model.save_adj(root='./', name=f'mod_adj')
|
60 |
# model.save_features(root='./', name='mod_features')
|
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
8 |
+
import os
|
9 |
+
import csv
|
10 |
|
11 |
parser = argparse.ArgumentParser()
|
12 |
+
parser.add_argument('--seed', type=int, default=50, help='Random seed.')
|
13 |
+
parser.add_argument('--dataset', type=str, default='pubmed', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
|
14 |
+
parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
|
15 |
+
parser.add_argument('--ptb_type', type=str, default='minmax', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
16 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
17 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
18 |
parser.add_argument('--k', type=int, default=50, help='Truncated Components.')
|
19 |
+
parser.add_argument('--gpu', type=int, default=5, help='GPU device ID (default: 0)')
|
20 |
|
21 |
args = parser.parse_args()
|
22 |
args.cuda = torch.cuda.is_available()
|
23 |
print('cuda: %s' % args.cuda)
|
24 |
+
device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
|
25 |
+
|
26 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = str(args.gpu)
|
27 |
|
28 |
# make sure you use the same data splits as you generated attacks
|
29 |
np.random.seed(args.seed)
|
|
|
54 |
gcn = gcn.to(device)
|
55 |
gcn.fit(features, perturbed_adj, labels, idx_train, idx_val, k=args.k, verbose=True)
|
56 |
gcn.eval()
|
57 |
+
test_acc = gcn.test(idx_test)
|
58 |
+
return test_acc
|
59 |
|
60 |
|
61 |
def main():
|
62 |
|
63 |
+
acc = test_svd(perturbed_adj)
|
64 |
+
|
65 |
+
print(acc)
|
66 |
+
# record result
|
67 |
+
csv_dir = "../result"
|
68 |
+
os.makedirs(csv_dir, exist_ok=True)
|
69 |
+
|
70 |
+
csv_filename = os.path.join(csv_dir, f"SVD_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
71 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {args.k} ", f" {acc}"]
|
72 |
+
|
73 |
+
# 写入 CSV 文件
|
74 |
+
try:
|
75 |
+
file_exists = os.path.isfile(csv_filename)
|
76 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
77 |
+
writer = csv.writer(csvfile)
|
78 |
+
if not file_exists:
|
79 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "svd_k " "accuracy"])
|
80 |
+
writer.writerow(row)
|
81 |
+
except Exception as e:
|
82 |
+
print(f"[Error] Failed to write CSV: {e}")
|
83 |
# # if you want to save the modified adj/features, uncomment the code below
|
84 |
# model.save_adj(root='./', name=f'mod_adj')
|
85 |
# model.save_features(root='./', name='mod_features')
|
examples/graph/cgscore_experiments/defense_method/GNNGuard.py
CHANGED
@@ -5,6 +5,8 @@ from deeprobust.graph.defense.gcn_guard import GCNGuard
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset
|
7 |
from deeprobust.graph.data import PtbDataset, PrePtbDataset
|
|
|
|
|
8 |
|
9 |
import argparse
|
10 |
from scipy import sparse
|
@@ -12,14 +14,15 @@ from scipy import sparse
|
|
12 |
parser = argparse.ArgumentParser()
|
13 |
parser.add_argument('--seed', type=int, default=15, help='Random seed')
|
14 |
parser.add_argument('--GNNGuard', type=bool, default=True, choices=[True, False])
|
15 |
-
parser.add_argument('--dataset', type=str, default='
|
16 |
-
parser.add_argument('--ptb_rate', type=float, default=0.
|
17 |
-
parser.add_argument('--ptb_type', type=str, default='
|
|
|
18 |
|
19 |
args = parser.parse_args()
|
20 |
args.cuda = torch.cuda.is_available()
|
21 |
print('cuda: %s' % args.cuda)
|
22 |
-
device = torch.device("cuda:
|
23 |
|
24 |
np.random.seed(args.seed)
|
25 |
torch.manual_seed(args.seed)
|
@@ -39,7 +42,7 @@ perturbed_adj = sp.csr_matrix(perturbed_adj.to('cpu').numpy())
|
|
39 |
def test(adj):
|
40 |
# """defense models"""
|
41 |
''' testing model '''
|
42 |
-
gcn = GCNGuard(nfeat=features.shape[1], nclass=labels.max().item() + 1, nhid=16,
|
43 |
dropout=0.5, with_relu=False, with_bias=True, weight_decay=5e-4, device=device)
|
44 |
gcn = gcn.to(device)
|
45 |
|
@@ -57,7 +60,23 @@ def main():
|
|
57 |
# test(adj)
|
58 |
#
|
59 |
print('=== testing GCN on Mettacked graph ===')
|
60 |
-
test(perturbed_adj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
if __name__ == '__main__':
|
63 |
main()
|
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset
|
7 |
from deeprobust.graph.data import PtbDataset, PrePtbDataset
|
8 |
+
import os
|
9 |
+
import csv
|
10 |
|
11 |
import argparse
|
12 |
from scipy import sparse
|
|
|
14 |
parser = argparse.ArgumentParser()
|
15 |
parser.add_argument('--seed', type=int, default=15, help='Random seed')
|
16 |
parser.add_argument('--GNNGuard', type=bool, default=True, choices=[True, False])
|
17 |
+
parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
|
18 |
+
parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
|
19 |
+
parser.add_argument('--ptb_type', type=str, default='minmax', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
20 |
+
parser.add_argument('--gpu', type=int, default=1, help='GPU device ID (default: 0)')
|
21 |
|
22 |
args = parser.parse_args()
|
23 |
args.cuda = torch.cuda.is_available()
|
24 |
print('cuda: %s' % args.cuda)
|
25 |
+
device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
|
26 |
|
27 |
np.random.seed(args.seed)
|
28 |
torch.manual_seed(args.seed)
|
|
|
42 |
def test(adj):
|
43 |
# """defense models"""
|
44 |
''' testing model '''
|
45 |
+
gcn = GCNGuard(nfeat=features.shape[1], nclass=labels.max().item() + 1, nhid=16, drop=True,
|
46 |
dropout=0.5, with_relu=False, with_bias=True, weight_decay=5e-4, device=device)
|
47 |
gcn = gcn.to(device)
|
48 |
|
|
|
60 |
# test(adj)
|
61 |
#
|
62 |
print('=== testing GCN on Mettacked graph ===')
|
63 |
+
acc = test(perturbed_adj)
|
64 |
+
|
65 |
+
csv_dir = "../result"
|
66 |
+
os.makedirs(csv_dir, exist_ok=True)
|
67 |
+
|
68 |
+
csv_filename = os.path.join(csv_dir, f"GNNGuard_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
69 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {acc}"]
|
70 |
+
|
71 |
+
try:
|
72 |
+
file_exists = os.path.isfile(csv_filename)
|
73 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
74 |
+
writer = csv.writer(csvfile)
|
75 |
+
if not file_exists:
|
76 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "accuracy"])
|
77 |
+
writer.writerow(row)
|
78 |
+
except Exception as e:
|
79 |
+
print(f"[Error] Failed to write CSV: {e}")
|
80 |
|
81 |
if __name__ == '__main__':
|
82 |
main()
|
examples/graph/cgscore_experiments/defense_method/ProGNN.py
CHANGED
@@ -5,12 +5,16 @@ from deeprobust.graph.defense import GCNJaccard, GCN, ProGNN
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
|
|
|
|
8 |
|
9 |
parser = argparse.ArgumentParser()
|
10 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
11 |
-
|
|
|
12 |
parser.add_argument('--ptb_type', type=str, default='clean', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
13 |
parser.add_argument('--ptb_rate', type=float, default=0.0, help='pertubation rate')
|
|
|
14 |
parser.add_argument('--epochs', type=int, default=200, help='Number of epochs to train.')
|
15 |
|
16 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
@@ -30,9 +34,11 @@ parser.add_argument('--outer_steps', type=int, default=1, help='steps for outer
|
|
30 |
parser.add_argument('--lr_adj', type=float, default=0.01, help='lr for training adj')
|
31 |
parser.add_argument('--symmetric', action='store_true', default=False, help='whether use symmetric matrix')
|
32 |
|
|
|
|
|
33 |
args = parser.parse_args()
|
34 |
args.cuda = torch.cuda.is_available()
|
35 |
-
device = torch.device("cuda:
|
36 |
print('Using device:', device)
|
37 |
|
38 |
# make sure you use the same data splits as you generated attacks
|
@@ -70,11 +76,28 @@ def test_prognn(features, adj, labels):
|
|
70 |
dropout=args.dropout, device=device).to(device)
|
71 |
prognn = ProGNN(model, args, device)
|
72 |
prognn.fit(features, adj, labels, idx_train, idx_val)
|
73 |
-
prognn.test(features, labels, idx_test)
|
|
|
|
|
74 |
|
75 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
if __name__ == '__main__':
|
80 |
main()
|
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
8 |
+
import os
|
9 |
+
import csv
|
10 |
|
11 |
parser = argparse.ArgumentParser()
|
12 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
13 |
+
|
14 |
+
parser.add_argument('--dataset', type=str, default='pubmed', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
|
15 |
parser.add_argument('--ptb_type', type=str, default='clean', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
16 |
parser.add_argument('--ptb_rate', type=float, default=0.0, help='pertubation rate')
|
17 |
+
|
18 |
parser.add_argument('--epochs', type=int, default=200, help='Number of epochs to train.')
|
19 |
|
20 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
|
|
34 |
parser.add_argument('--lr_adj', type=float, default=0.01, help='lr for training adj')
|
35 |
parser.add_argument('--symmetric', action='store_true', default=False, help='whether use symmetric matrix')
|
36 |
|
37 |
+
parser.add_argument('--gpu', type=int, default=6, help='GPU device ID (default: 0)')
|
38 |
+
|
39 |
args = parser.parse_args()
|
40 |
args.cuda = torch.cuda.is_available()
|
41 |
+
device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
|
42 |
print('Using device:', device)
|
43 |
|
44 |
# make sure you use the same data splits as you generated attacks
|
|
|
76 |
dropout=args.dropout, device=device).to(device)
|
77 |
prognn = ProGNN(model, args, device)
|
78 |
prognn.fit(features, adj, labels, idx_train, idx_val)
|
79 |
+
acc = prognn.test(features, labels, idx_test)
|
80 |
+
return acc
|
81 |
+
|
82 |
|
83 |
def main():
|
84 |
+
|
85 |
+
acc = test_prognn(features, perturbed_adj, labels)
|
86 |
+
csv_dir = "../result"
|
87 |
+
os.makedirs(csv_dir, exist_ok=True)
|
88 |
+
|
89 |
+
csv_filename = os.path.join(csv_dir, f"ProGNN_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
90 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {acc}"]
|
91 |
|
92 |
+
try:
|
93 |
+
file_exists = os.path.isfile(csv_filename)
|
94 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
95 |
+
writer = csv.writer(csvfile)
|
96 |
+
if not file_exists:
|
97 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "accuracy"])
|
98 |
+
writer.writerow(row)
|
99 |
+
except Exception as e:
|
100 |
+
print(f"[Error] Failed to write CSV: {e}")
|
101 |
|
102 |
if __name__ == '__main__':
|
103 |
main()
|
examples/graph/cgscore_experiments/defense_method/RGCN.py
CHANGED
@@ -5,20 +5,23 @@ from deeprobust.graph.defense import RGCN
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
|
|
|
|
8 |
|
9 |
parser = argparse.ArgumentParser()
|
10 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
11 |
-
parser.add_argument('--dataset', type=str, default='
|
12 |
-
parser.add_argument('--ptb_rate', type=float, default=0.
|
13 |
-
parser.add_argument('--ptb_type', type=str, default='
|
14 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
15 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
|
|
16 |
|
17 |
|
18 |
args = parser.parse_args()
|
19 |
args.cuda = torch.cuda.is_available()
|
20 |
print('cuda: %s' % args.cuda)
|
21 |
-
device = torch.device("cuda:
|
22 |
|
23 |
# make sure you use the same data splits as you generated attacks
|
24 |
np.random.seed(args.seed)
|
@@ -52,12 +55,29 @@ def test_rgcn(adj):
|
|
52 |
gcn = gcn.to(device)
|
53 |
gcn.fit(features, adj, labels, idx_train, idx_val, train_iters=200, verbose=True)
|
54 |
gcn.eval()
|
55 |
-
gcn.test(idx_test)
|
|
|
56 |
|
57 |
|
58 |
def main():
|
59 |
|
60 |
-
test_rgcn(perturbed_adj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
# # if you want to save the modified adj/features, uncomment the code below
|
62 |
# model.save_adj(root='./', name=f'mod_adj')
|
63 |
# model.save_features(root='./', name='mod_features')
|
|
|
5 |
from deeprobust.graph.utils import *
|
6 |
from deeprobust.graph.data import Dataset, PrePtbDataset
|
7 |
import argparse
|
8 |
+
import os
|
9 |
+
import csv
|
10 |
|
11 |
parser = argparse.ArgumentParser()
|
12 |
parser.add_argument('--seed', type=int, default=15, help='Random seed.')
|
13 |
+
parser.add_argument('--dataset', type=str, default='Flickr', choices=['cora', 'cora_ml', 'citeseer', 'polblogs', 'pubmed', 'Flickr'], help='dataset')
|
14 |
+
parser.add_argument('--ptb_rate', type=float, default=0.25, help='pertubation rate')
|
15 |
+
parser.add_argument('--ptb_type', type=str, default='minmax', choices=['clean', 'meta', 'dice', 'minmax', 'pgd', 'random'], help='attack type')
|
16 |
parser.add_argument('--hidden', type=int, default=16, help='Number of hidden units.')
|
17 |
parser.add_argument('--dropout', type=float, default=0.5, help='Dropout rate (1 - keep probability).')
|
18 |
+
parser.add_argument('--gpu', type=int, default=0, help='GPU device ID (default: 0)')
|
19 |
|
20 |
|
21 |
args = parser.parse_args()
|
22 |
args.cuda = torch.cuda.is_available()
|
23 |
print('cuda: %s' % args.cuda)
|
24 |
+
device = torch.device(f"cuda:{args.gpu}" if torch.cuda.is_available() else "cpu")
|
25 |
|
26 |
# make sure you use the same data splits as you generated attacks
|
27 |
np.random.seed(args.seed)
|
|
|
55 |
gcn = gcn.to(device)
|
56 |
gcn.fit(features, adj, labels, idx_train, idx_val, train_iters=200, verbose=True)
|
57 |
gcn.eval()
|
58 |
+
acc = gcn.test(idx_test)
|
59 |
+
return acc
|
60 |
|
61 |
|
62 |
def main():
|
63 |
|
64 |
+
acc = test_rgcn(perturbed_adj)
|
65 |
+
|
66 |
+
csv_dir = "../result"
|
67 |
+
os.makedirs(csv_dir, exist_ok=True)
|
68 |
+
|
69 |
+
csv_filename = os.path.join(csv_dir, f"RGCN_{args.dataset}_{args.ptb_type}_{args.ptb_rate}.csv")
|
70 |
+
row = [f"{args.dataset} ", f" {args.ptb_type} ", f" {args.ptb_rate} ", f" {acc}"]
|
71 |
+
|
72 |
+
try:
|
73 |
+
file_exists = os.path.isfile(csv_filename)
|
74 |
+
with open(csv_filename, 'a', newline='') as csvfile:
|
75 |
+
writer = csv.writer(csvfile)
|
76 |
+
if not file_exists:
|
77 |
+
writer.writerow(["dataset ", "ptb_type ", "ptb_rate ", "accuracy"])
|
78 |
+
writer.writerow(row)
|
79 |
+
except Exception as e:
|
80 |
+
print(f"[Error] Failed to write CSV: {e}")
|
81 |
# # if you want to save the modified adj/features, uncomment the code below
|
82 |
# model.save_adj(root='./', name=f'mod_adj')
|
83 |
# model.save_features(root='./', name='mod_features')
|
examples/graph/cgscore_experiments/result/GAT_Flickr_clean_0.0.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , clean , 0.0 , 0.4783828382838284
|
3 |
+
Flickr , clean , 0.0 , 0.4641914191419142
|
examples/graph/cgscore_experiments/result/GAT_Flickr_dice_0.25.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , dice , 0.25 , 0.2811881188118812
|
3 |
+
Flickr , dice , 0.25 , 0.27937293729372936
|
examples/graph/cgscore_experiments/result/GAT_Flickr_minmax_0.25.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , minmax , 0.25 , 0.11204620462046205
|
3 |
+
Flickr , minmax , 0.25 , 0.11716171617161716
|
examples/graph/cgscore_experiments/result/GAT_pubmed_clean_0.0.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
pubmed , clean , 0.0 , 0.8510206669202486
|
examples/graph/cgscore_experiments/result/GCN_Flickr_clean_0.0.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , clean , 0.0 , 0.5414191419141914
|
3 |
+
Flickr , clean , 0.0 , 0.5597359735973597
|
examples/graph/cgscore_experiments/result/GCN_Flickr_dice_0.25.csv
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , dice , 0.25 , 0.511056105610561
|
3 |
+
Flickr , dice , 0.25 , 0.5151815181518152
|
4 |
+
Flickr , dice , 0.25 , 0.5115511551155115
|
5 |
+
Flickr , dice , 0.25 , 0.5171617161716172
|
6 |
+
Flickr , dice , 0.25 , 0.5136963696369637
|
examples/graph/cgscore_experiments/result/GCN_Flickr_minmax_0.25.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , minmax , 0.25 , 0.116996699669967
|
3 |
+
Flickr , minmax , 0.25 , 0.14570957095709572
|
4 |
+
Flickr , minmax , 0.25 , 0.11831683168316831
|
examples/graph/cgscore_experiments/result/GCN_pubmed_minmax_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
pubmed , minmax , 0.25 , 0.5567389374920756
|
examples/graph/cgscore_experiments/result/GNNGuard_Flickr_clean_0.0.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , clean , 0.0 , 0.7541254125412541
|
examples/graph/cgscore_experiments/result/GNNGuard_Flickr_dice_0.25.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , dice , 0.25 , 0.7419141914191419
|
3 |
+
Flickr , dice , 0.25 , 0.7422442244224422
|
examples/graph/cgscore_experiments/result/GNNGuard_citeseer_clean_0.0.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
citeseer , clean , 0.0 , 0.710308056872038
|
examples/graph/cgscore_experiments/result/GNNGuard_citeseer_meta_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
citeseer , meta , 0.25 , 0.6475118483412323
|
examples/graph/cgscore_experiments/result/GNNGuard_cora_clean_0.0.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
cora , clean , 0.0 , 0.7801810865191148
|
examples/graph/cgscore_experiments/result/GNNGuard_cora_dice_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
cora , dice , 0.25 , 0.7550301810865192
|
examples/graph/cgscore_experiments/result/GNNGuard_cora_minmax_0.25.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
cora , minmax , 0.25 , 0.7057344064386318
|
3 |
+
cora , minmax , 0.25 , 0.7087525150905433
|
examples/graph/cgscore_experiments/result/GNNGuard_polblogs_meta_0.25.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
polblogs , meta , 0.25 , 0.4877300613496933
|
3 |
+
polblogs , meta , 0.25 , 0.4877300613496933
|
examples/graph/cgscore_experiments/result/GNNGuard_polblogs_minmax_0.25.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
polblogs , minmax , 0.25 , 0.4877300613496933
|
3 |
+
polblogs , minmax , 0.25 , 0.4877300613496933
|
examples/graph/cgscore_experiments/result/GNNGuard_pubmed_dice_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
pubmed , dice , 0.25 , 0.8228730822873083
|
examples/graph/cgscore_experiments/result/Jaccard_Flickr_clean_0.0.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
Flickr , clean , 0.0 , 0.05 , 0.7282178217821782
|
3 |
+
Flickr , clean , 0.0 , 0.09 , 0.7422442244224422
|
4 |
+
Flickr , clean , 0.0 , 0.2 , 0.7333333333333334
|
5 |
+
Flickr , clean , 0.0 , 0.06 , 0.7366336633663366
|
6 |
+
Flickr , clean , 0.0 , 0.1 , 0.7404290429042905
|
7 |
+
Flickr , clean , 0.0 , 0.4 , 0.717986798679868
|
8 |
+
Flickr , clean , 0.0 , 0.03 , 0.7156765676567657
|
9 |
+
Flickr , clean , 0.0 , 0.08 , 0.7475247524752475
|
10 |
+
Flickr , clean , 0.0 , 0.5 , 0.7358085808580859
|
11 |
+
Flickr , clean , 0.0 , 0.04 , 0.7288778877887789
|
12 |
+
Flickr , clean , 0.0 , 0.07 , 0.7410891089108911
|
13 |
+
Flickr , clean , 0.0 , 0.02 , 0.6950495049504951
|
14 |
+
Flickr , clean , 0.0 , 0.3 , 0.7242574257425742
|
15 |
+
Flickr , clean , 0.0 , 0.01 , 0.6866336633663367
|
examples/graph/cgscore_experiments/result/Jaccard_Flickr_dice_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
Flickr , dice , 0.25 , 0.1 , 0.7334983498349835
|
examples/graph/cgscore_experiments/result/Jaccard_Flickr_minmax_0.25.csv
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
Flickr , minmax , 0.25 , 0.1 , 0.7336633663366336
|
3 |
+
Flickr , minmax , 0.25 , 0.04 , 0.721947194719472
|
4 |
+
Flickr , minmax , 0.25 , 0.5 , 0.7338283828382839
|
5 |
+
Flickr , minmax , 0.25 , 0.01 , 0.6072607260726073
|
6 |
+
Flickr , minmax , 0.25 , 0.06 , 0.7382838283828383
|
examples/graph/cgscore_experiments/result/Jaccard_citeseer_clean_0.0.csv
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
citeseer , clean , 0.0 , 0.07 , 0.7132701421800949
|
3 |
+
citeseer , clean , 0.0 , 0.03 , 0.729265402843602
|
4 |
+
citeseer , clean , 0.0 , 0.06 , 0.7109004739336493
|
5 |
+
citeseer , clean , 0.0 , 0.05 , 0.7162322274881517
|
6 |
+
citeseer , clean , 0.0 , 0.01 , 0.7209715639810427
|
7 |
+
citeseer , clean , 0.0 , 0.08 , 0.7138625592417062
|
8 |
+
citeseer , clean , 0.0 , 0.5 , 0.6255924170616114
|
9 |
+
citeseer , clean , 0.0 , 0.4 , 0.6558056872037915
|
10 |
+
citeseer , clean , 0.0 , 0.3 , 0.6463270142180095
|
11 |
+
citeseer , clean , 0.0 , 0.3 , 0.6575829383886257
|
12 |
+
citeseer , clean , 0.0 , 0.1 , 0.6990521327014219
|
13 |
+
citeseer , clean , 0.0 , 0.03 , 0.7162322274881517
|
14 |
+
citeseer , clean , 0.0 , 0.01 , 0.71978672985782
|
15 |
+
citeseer , clean , 0.0 , 0.2 , 0.6652843601895735
|
16 |
+
citeseer , clean , 0.0 , 0.08 , 0.7008293838862559
|
17 |
+
citeseer , clean , 0.0 , 0.04 , 0.7221563981042655
|
18 |
+
citeseer , clean , 0.0 , 0.5 , 0.6332938388625593
|
19 |
+
citeseer , clean , 0.0 , 0.05 , 0.7097156398104266
|
20 |
+
citeseer , clean , 0.0 , 0.06 , 0.7227488151658769
|
21 |
+
citeseer , clean , 0.0 , 0.4 , 0.6712085308056872
|
22 |
+
citeseer , clean , 0.0 , 0.05 , 0.7162322274881517
|
23 |
+
citeseer , clean , 0.0 , 0.09 , 0.6978672985781991
|
24 |
+
citeseer , clean , 0.0 , 0.07 , 0.715047393364929
|
25 |
+
citeseer , clean , 0.0 , 0.3 , 0.6528436018957346
|
26 |
+
citeseer , clean , 0.0 , 0.03 , 0.7257109004739337
|
27 |
+
citeseer , clean , 0.0 , 0.02 , 0.7215639810426541
|
28 |
+
citeseer , clean , 0.0 , 0.06 , 0.7209715639810427
|
29 |
+
citeseer , clean , 0.0 , 0.2 , 0.6753554502369669
|
30 |
+
citeseer , clean , 0.0 , 0.1 , 0.6937203791469195
|
31 |
+
citeseer , clean , 0.0 , 0.08 , 0.7026066350710901
|
32 |
+
citeseer , clean , 0.0 , 0.01 , 0.7298578199052134
|
33 |
+
citeseer , clean , 0.0 , 0.4 , 0.6658767772511849
|
34 |
+
citeseer , clean , 0.0 , 0.5 , 0.6380331753554502
|
35 |
+
citeseer , clean , 0.0 , 0.04 , 0.7209715639810427
|
examples/graph/cgscore_experiments/result/Jaccard_citeseer_meta_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
citeseer , meta , 0.25 , 0.2 , 0.6362559241706162
|
3 |
+
citeseer , meta , 0.25 , 0.3 , 0.625
|
4 |
+
citeseer , meta , 0.25 , 0.1 , 0.7020142180094787
|
5 |
+
citeseer , meta , 0.25 , 0.01 , 0.6107819905213271
|
6 |
+
citeseer , meta , 0.25 , 0.5 , 0.658175355450237
|
7 |
+
citeseer , meta , 0.25 , 0.06 , 0.6978672985781991
|
8 |
+
citeseer , meta , 0.25 , 0.09 , 0.6978672985781991
|
9 |
+
citeseer , meta , 0.25 , 0.08 , 0.6907582938388626
|
10 |
+
citeseer , meta , 0.25 , 0.4 , 0.6611374407582938
|
11 |
+
citeseer , meta , 0.25 , 0.03 , 0.6546208530805687
|
12 |
+
citeseer , meta , 0.25 , 0.04 , 0.667654028436019
|
13 |
+
citeseer , meta , 0.25 , 0.02 , 0.6433649289099527
|
14 |
+
citeseer , meta , 0.25 , 0.05 , 0.6694312796208531
|
15 |
+
citeseer , meta , 0.25 , 0.07 , 0.7014218009478673
|
examples/graph/cgscore_experiments/result/Jaccard_citeseer_minmax_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
citeseer , minmax , 0.25 , 0.05 , 0.6877962085308057
|
3 |
+
citeseer , minmax , 0.25 , 0.02 , 0.6789099526066351
|
4 |
+
citeseer , minmax , 0.25 , 0.08 , 0.7002369668246446
|
5 |
+
citeseer , minmax , 0.25 , 0.09 , 0.6949052132701422
|
6 |
+
citeseer , minmax , 0.25 , 0.2 , 0.6587677725118484
|
7 |
+
citeseer , minmax , 0.25 , 0.04 , 0.6623222748815166
|
8 |
+
citeseer , minmax , 0.25 , 0.03 , 0.6931279620853081
|
9 |
+
citeseer , minmax , 0.25 , 0.3 , 0.648696682464455
|
10 |
+
citeseer , minmax , 0.25 , 0.1 , 0.7120853080568721
|
11 |
+
citeseer , minmax , 0.25 , 0.07 , 0.7014218009478673
|
12 |
+
citeseer , minmax , 0.25 , 0.01 , 0.691350710900474
|
13 |
+
citeseer , minmax , 0.25 , 0.5 , 0.6617298578199052
|
14 |
+
citeseer , minmax , 0.25 , 0.06 , 0.6954976303317536
|
15 |
+
citeseer , minmax , 0.25 , 0.4 , 0.6718009478672986
|
examples/graph/cgscore_experiments/result/Jaccard_citeseer_random_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
citeseer , random , 0.25 , 0.08 , 0.6907582938388626
|
3 |
+
citeseer , random , 0.25 , 0.09 , 0.7120853080568721
|
4 |
+
citeseer , random , 0.25 , 0.4 , 0.6516587677725119
|
5 |
+
citeseer , random , 0.25 , 0.2 , 0.6777251184834123
|
6 |
+
citeseer , random , 0.25 , 0.04 , 0.6978672985781991
|
7 |
+
citeseer , random , 0.25 , 0.1 , 0.7008293838862559
|
8 |
+
citeseer , random , 0.25 , 0.07 , 0.7138625592417062
|
9 |
+
citeseer , random , 0.25 , 0.5 , 0.6433649289099527
|
10 |
+
citeseer , random , 0.25 , 0.01 , 0.6836492890995262
|
11 |
+
citeseer , random , 0.25 , 0.3 , 0.6516587677725119
|
12 |
+
citeseer , random , 0.25 , 0.06 , 0.7209715639810427
|
13 |
+
citeseer , random , 0.25 , 0.05 , 0.705568720379147
|
14 |
+
citeseer , random , 0.25 , 0.02 , 0.7079383886255924
|
15 |
+
citeseer , random , 0.25 , 0.03 , 0.7114928909952607
|
examples/graph/cgscore_experiments/result/Jaccard_cora_minmax_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
cora , minmax , 0.25 , 0.5 , 0.6091549295774649
|
3 |
+
cora , minmax , 0.25 , 0.4 , 0.6307847082494971
|
4 |
+
cora , minmax , 0.25 , 0.05 , 0.6830985915492959
|
5 |
+
cora , minmax , 0.25 , 0.02 , 0.6584507042253521
|
6 |
+
cora , minmax , 0.25 , 0.1 , 0.7087525150905433
|
7 |
+
cora , minmax , 0.25 , 0.09 , 0.7263581488933603
|
8 |
+
cora , minmax , 0.25 , 0.2 , 0.6498993963782697
|
9 |
+
cora , minmax , 0.25 , 0.01 , 0.6609657947686117
|
10 |
+
cora , minmax , 0.25 , 0.06 , 0.7223340040241449
|
11 |
+
cora , minmax , 0.25 , 0.07 , 0.7067404426559357
|
12 |
+
cora , minmax , 0.25 , 0.03 , 0.7188128772635816
|
13 |
+
cora , minmax , 0.25 , 0.3 , 0.6453722334004025
|
14 |
+
cora , minmax , 0.25 , 0.04 , 0.6770623742454729
|
15 |
+
cora , minmax , 0.25 , 0.08 , 0.7188128772635816
|
examples/graph/cgscore_experiments/result/Jaccard_cora_random_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
cora , random , 0.25 , 0.02 , 0.7711267605633804
|
3 |
+
cora , random , 0.25 , 0.03 , 0.7570422535211269
|
4 |
+
cora , random , 0.25 , 0.2 , 0.6448692152917506
|
5 |
+
cora , random , 0.25 , 0.08 , 0.7198189134808853
|
6 |
+
cora , random , 0.25 , 0.5 , 0.6066398390342053
|
7 |
+
cora , random , 0.25 , 0.09 , 0.7268611670020121
|
8 |
+
cora , random , 0.25 , 0.1 , 0.6976861167002013
|
9 |
+
cora , random , 0.25 , 0.4 , 0.6242454728370221
|
10 |
+
cora , random , 0.25 , 0.01 , 0.7711267605633804
|
11 |
+
cora , random , 0.25 , 0.05 , 0.7525150905432596
|
12 |
+
cora , random , 0.25 , 0.04 , 0.7580482897384306
|
13 |
+
cora , random , 0.25 , 0.06 , 0.7535211267605635
|
14 |
+
cora , random , 0.25 , 0.3 , 0.6343058350100604
|
15 |
+
cora , random , 0.25 , 0.07 , 0.7263581488933603
|
examples/graph/cgscore_experiments/result/Jaccard_polblogs_clean_0.0.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
polblogs , clean , 0.0 , 0.2 , 0.5132924335378324
|
3 |
+
polblogs , clean , 0.0 , 0.3 , 0.5173824130879346
|
4 |
+
polblogs , clean , 0.0 , 0.06 , 0.5071574642126789
|
5 |
+
polblogs , clean , 0.0 , 0.07 , 0.5204498977505113
|
6 |
+
polblogs , clean , 0.0 , 0.08 , 0.5071574642126789
|
7 |
+
polblogs , clean , 0.0 , 0.04 , 0.5030674846625768
|
8 |
+
polblogs , clean , 0.0 , 0.09 , 0.5173824130879346
|
9 |
+
polblogs , clean , 0.0 , 0.5 , 0.5051124744376279
|
10 |
+
polblogs , clean , 0.0 , 0.05 , 0.5204498977505113
|
11 |
+
polblogs , clean , 0.0 , 0.03 , 0.5286298568507158
|
12 |
+
polblogs , clean , 0.0 , 0.01 , 0.49386503067484666
|
13 |
+
polblogs , clean , 0.0 , 0.4 , 0.5265848670756647
|
14 |
+
polblogs , clean , 0.0 , 0.02 , 0.5173824130879346
|
15 |
+
polblogs , clean , 0.0 , 0.1 , 0.5040899795501023
|
examples/graph/cgscore_experiments/result/Jaccard_polblogs_dice_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
polblogs , dice , 0.25 , 0.09 , 0.5255623721881391
|
3 |
+
polblogs , dice , 0.25 , 0.4 , 0.5132924335378324
|
4 |
+
polblogs , dice , 0.25 , 0.08 , 0.5204498977505113
|
5 |
+
polblogs , dice , 0.25 , 0.05 , 0.4795501022494888
|
6 |
+
polblogs , dice , 0.25 , 0.1 , 0.4795501022494888
|
7 |
+
polblogs , dice , 0.25 , 0.5 , 0.5204498977505113
|
8 |
+
polblogs , dice , 0.25 , 0.07 , 0.5245398773006136
|
9 |
+
polblogs , dice , 0.25 , 0.2 , 0.5061349693251534
|
10 |
+
polblogs , dice , 0.25 , 0.03 , 0.5102249488752557
|
11 |
+
polblogs , dice , 0.25 , 0.06 , 0.5173824130879346
|
12 |
+
polblogs , dice , 0.25 , 0.01 , 0.5173824130879346
|
13 |
+
polblogs , dice , 0.25 , 0.02 , 0.5081799591002045
|
14 |
+
polblogs , dice , 0.25 , 0.3 , 0.5204498977505113
|
15 |
+
polblogs , dice , 0.25 , 0.04 , 0.514314928425358
|
examples/graph/cgscore_experiments/result/Jaccard_polblogs_meta_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
polblogs , meta , 0.25 , 0.2 , 0.5112474437627812
|
3 |
+
polblogs , meta , 0.25 , 0.1 , 0.5051124744376279
|
4 |
+
polblogs , meta , 0.25 , 0.01 , 0.49897750511247446
|
5 |
+
polblogs , meta , 0.25 , 0.06 , 0.48261758691206547
|
6 |
+
polblogs , meta , 0.25 , 0.5 , 0.5214723926380369
|
7 |
+
polblogs , meta , 0.25 , 0.4 , 0.49897750511247446
|
8 |
+
polblogs , meta , 0.25 , 0.07 , 0.5204498977505113
|
9 |
+
polblogs , meta , 0.25 , 0.09 , 0.47137014314928427
|
10 |
+
polblogs , meta , 0.25 , 0.03 , 0.49079754601227
|
11 |
+
polblogs , meta , 0.25 , 0.08 , 0.523517382413088
|
12 |
+
polblogs , meta , 0.25 , 0.04 , 0.5092024539877301
|
13 |
+
polblogs , meta , 0.25 , 0.3 , 0.5204498977505113
|
14 |
+
polblogs , meta , 0.25 , 0.05 , 0.5184049079754601
|
15 |
+
polblogs , meta , 0.25 , 0.02 , 0.4979550102249489
|
examples/graph/cgscore_experiments/result/Jaccard_pubmed_minmax_0.25.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,threshold ,accuracy
|
2 |
+
pubmed , minmax , 0.25 , 0.05 , 0.597629009762901
|
3 |
+
pubmed , minmax , 0.25 , 0.03 , 0.5685304932166857
|
4 |
+
pubmed , minmax , 0.25 , 0.3 , 0.8451248890579436
|
5 |
+
pubmed , minmax , 0.25 , 0.1 , 0.7615062761506277
|
6 |
+
pubmed , minmax , 0.25 , 0.01 , 0.5611132242931407
|
7 |
+
pubmed , minmax , 0.25 , 0.09 , 0.7393812603017624
|
8 |
+
pubmed , minmax , 0.25 , 0.04 , 0.5867249904906809
|
9 |
+
pubmed , minmax , 0.25 , 0.2 , 0.8496893622416636
|
10 |
+
pubmed , minmax , 0.25 , 0.07 , 0.6496766831494866
|
11 |
+
pubmed , minmax , 0.25 , 0.5 , 0.8383415747432484
|
12 |
+
pubmed , minmax , 0.25 , 0.4 , 0.8423988842398885
|
13 |
+
pubmed , minmax , 0.25 , 0.02 , 0.5549004691264106
|
14 |
+
pubmed , minmax , 0.25 , 0.06 , 0.6208951439076963
|
15 |
+
pubmed , minmax , 0.25 , 0.08 , 0.685495118549512
|
examples/graph/cgscore_experiments/result/ProGNN_Flickr_clean_0.0.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , clean , 0.0 , 0.44686468646864685
|
examples/graph/cgscore_experiments/result/ProGNN_Flickr_dice_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , dice , 0.25 , 0.7123762376237623
|
examples/graph/cgscore_experiments/result/ProGNN_Flickr_minmax_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
Flickr , minmax , 0.25 , 0.19686468646864685
|
examples/graph/cgscore_experiments/result/ProGNN_citeseer_dice_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
citeseer , dice , 0.25 , 0.7215639810426541
|
examples/graph/cgscore_experiments/result/ProGNN_citeseer_minmax_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
citeseer , minmax , 0.25 , 0.6990521327014219
|
examples/graph/cgscore_experiments/result/ProGNN_cora_minmax_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
cora , minmax , 0.25 , 0.6443661971830986
|
examples/graph/cgscore_experiments/result/ProGNN_polblogs_dice_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
polblogs , dice , 0.25 , 0.7474437627811862
|
examples/graph/cgscore_experiments/result/ProGNN_polblogs_minmax_0.25.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
dataset ,ptb_type ,ptb_rate ,accuracy
|
2 |
+
polblogs , minmax , 0.25 , 0.6073619631901841
|