Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Bang505 authored Feb 12, 2021
1 parent 11ce790 commit 2e37b01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions attacks/attack_0.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 10:51:25 2020
This code is for creat a sub-graph
@author: Bang
"""



from dgl.data import citation_graph as citegrh
Expand Down Expand Up @@ -67,16 +61,19 @@ def attack0(dataset_name, attack_node_arg, cuda):
feature_number = 1433
label_number = 7
data = citegrh.load_cora()
data1 = citegrh.load_cora()
if dataset_name == 'citeseer':
node_number=3327
feature_number =3703
label_number =6
data = citegrh.load_citeseer()
data1 = citegrh.load_citeseer()
if dataset_name == 'pubmed':
node_number=19717
feature_number = 500
label_number = 3
data = citegrh.load_pubmed()
data1 = citegrh.load_pubmed()

attack_node_number = int(node_number * attack_node_arg)
print("============================================================")
Expand Down Expand Up @@ -149,7 +146,6 @@ def attack0(dataset_name, attack_node_arg, cuda):
sub_graph_node_index.append(random.randint(0,node_number-1))


data1 = citegrh.load_cora()
labels1 = th.LongTensor(data1.labels)
test_mask1 = th.ByteTensor(data1.test_mask)

Expand Down Expand Up @@ -251,7 +247,6 @@ def attack0(dataset_name, attack_node_arg, cuda):
sub_test_mask = th.ByteTensor(test_mask)
#sub_g = DGLGraph(nx.from_numpy_matrix(sub_g))

data = citegrh.load_cora()
features = th.FloatTensor(data.features)
labels = th.LongTensor(data.labels)
train_mask = th.ByteTensor(data.train_mask)
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
parser.add_argument('--attack_type', type=int, default=0,
help="int id of attack type")

parser.add_argument('--dataset', type=str, default='cora',
parser.add_argument('--dataset', type=str, default='pubmed',
help="Dataset for the target model: (cora, citeseer, pubmed)")

parser.add_argument('--attack_node', type=float, default=0.25,
parser.add_argument('--attack_node', type=float, default=0.05,
help='proportion of the attack nodes')

parser.add_argument('--shadow_dataset_size', type=float, default=1,
Expand Down

0 comments on commit 2e37b01

Please sign in to comment.