Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Munkhtenger19 committed May 29, 2024
1 parent 36e225f commit ecb9c68
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 108 deletions.
122 changes: 18 additions & 104 deletions configs/default_experiment.yaml
Original file line number Diff line number Diff line change
@@ -1,121 +1,35 @@
output_dir: ./output10
output_dir: ./outputs
resume_output: True
# csv_save: True
# esd: True
csv_save: True
experiment_templates:
- name: Local attack_3
seed: [6]
- name: experiments
seed: [0, 1, 2]
device: cuda
model:
- name: [GCN2]
- name: [GPRGNN, GCN_DPR, AirGNN]
params:
hidden_channels: 64
dataset:
name: [Cora]
# name: [CoraFull, CS, Physics, Computers, Photo, CoraCitationFull, DBLP, PubMedCitationFull, Reddit] # ogbn-arxiv
name: [Cora, CS]
root: ./datasets
make_undirected: false
# params:
# split: full
# train_ratio: 0.6
# test_ratio: 0.2
# val_ratio: 0.2
# transforms:
# - name: ToUndirected
# - name: NormalizeFeatures
# - name: Constant
# params:
# value: 0.8

transforms:
- name: NormalizeFeatures
- name: Constant
params:
value: 0.8
attack:
- scope: global
name: [GRBCD]
name: [PRBCD, GRBCD, DICE]
type: poison
epsilon: [0.4]
# nodes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# nodes_topk: 10
# min_node_degree: 2
# - scope: global
# name: FGSM
# type: poison
# epsilon: [0.5]
# - scope: global
# name: GRBCD
# type: poison
# epsilon: [0.25]

# - scope: local
# name: [LocalDICE]
# type: evasion
# epsilon: [0.6]
# nodes_topk: 10
# min_node_degree: 2

# params:
# block_size: 100000
# - scope: local
# name: [LocalPRBCD, LocalDICE]
# type: [poison, evasion]
# epsilon: [0.3]
# nodes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# - scope: local
# name: Nettack
# type: evasion
# epsilon: [0.2]
# nodes: [0]


epsilon: [0.1, 0.2]
training:
max_epochs: 102
patience: 90

max_epochs: 100
patience: 80
optimizer:
# name: Adam
name: [Adam]
name: [Adam, SGD]
params:
lr: 0.01
# weight_decay: 0.0005

weight_decay: 0.0005
loss:
name: CE

# - name: Another Experiment
# seed: [0, 1]
# device: cuda

# model:
# name: GAT
# params:
# hidden_channels: [64, 128]

# dataset:
# name: cora
# root: ./datasets
# make_undirected: True

# attack:
# - scope: global
# name: DICE
# type: poison
# epsilon: [0.2, 0.3]
# - scope: local
# name: localDICE
# type: evasion
# epsilon: [0.05, 0.1, 0.2]
# nodes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

# training:
# max_epochs: 400
# patience: 200

# optimizer:
# name: adam
# params:
# lr: [0.01]
# weight_decay: [0.0005]

# loss:
# name: CE



name: CE
28 changes: 28 additions & 0 deletions configs/demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
output_dir: output_demo
cache_dir: cache_demo
experiment_templates:
- name: GCN_Cora_DICE_Evasion
seed: 0
device: cuda
model:
name: GCN
params:
hidden_channels: 64
dropout: 0.5
dataset:
name: Cora
make_undirected: True
attack:
scope: global
type: evasion
name: DICE
epsilon: 0.1
training:
max_epochs: 200
patience: 20
optimizer:
name: Adam
params:
lr: 0.01
loss:
name: CE
4 changes: 4 additions & 0 deletions custom_components/attacks/local_attacks/local_dice.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
DICE implementation is adapted from: https://github.com/sigeisler/robustness_of_gnns_at_scale/blob/main/rgnn_at_scale/attacks/local_dice.py
"""

import torch
from torch_sparse import SparseTensor

Expand Down
4 changes: 4 additions & 0 deletions custom_components/attacks/local_attacks/local_prbcd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
DICE implementation is adapted from: https://github.com/sigeisler/robustness_of_gnns_at_scale/blob/main/rgnn_at_scale/attacks/local_prbcd.py
"""

from collections import defaultdict

import math
Expand Down
5 changes: 5 additions & 0 deletions custom_components/models/AirGNN.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
Adapted from DeepRobust project: https://github.com/DSE-MSU/DeepRobust/blob/master/deeprobust/graph/defense_pyg/gcn.py
"""


import torch
import torch.nn as nn
import torch.nn.functional as F
Expand Down
2 changes: 1 addition & 1 deletion custom_components/models/GCN_DPR.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
from torch_geometric.nn import GCNConv
# from .base_model import BaseModel

from torch_sparse import coalesce, SparseTensor, matmul
from custom_components.utils import ensure_contiguousness

Expand Down
7 changes: 6 additions & 1 deletion custom_components/models/GPR.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""
Adapted from DeepRobust project: https://github.com/DSE-MSU/DeepRobust/blob/master/deeprobust/graph/defense_pyg/gcn.py
"""


import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_sparse import SparseTensor, matmul
from torch_geometric.nn import GCNConv, SAGEConv, GATConv, APPNP, MessagePassing
from torch_geometric.nn.conv.gcn_conv import gcn_norm
import scipy.sparse

import numpy as np
from gnn_toolbox.registry import register_model

Expand Down
3 changes: 1 addition & 2 deletions custom_components/models/SAGE.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import torch.nn as nn
import torch.nn.functional as F
from torch_sparse import SparseTensor, matmul
# from torch_geometric.nn import SAGEConv, GATConv, APPNP, MessagePassing
from torch_geometric.nn.conv.gcn_conv import gcn_norm
import scipy.sparse
import numpy as np
# from .base_model import BaseModel

from gnn_toolbox.registry import register_model

@register_model("SAGE")
Expand Down

0 comments on commit ecb9c68

Please sign in to comment.