From 0637c55e1dff82d40dde24df7b72b273dc9a9e4a Mon Sep 17 00:00:00 2001 From: Generall Date: Wed, 28 Dec 2022 00:00:50 +0800 Subject: [PATCH] improve robust tuto --- docs/docfile/tutorial/t_robust.rst | 62 +++++++++++++++++++++------ docs/docfile/tutorial_cn/t_robust.rst | 29 +++++++++++-- 2 files changed, 73 insertions(+), 18 deletions(-) diff --git a/docs/docfile/tutorial/t_robust.rst b/docs/docfile/tutorial/t_robust.rst index d0b8d7b..b747717 100644 --- a/docs/docfile/tutorial/t_robust.rst +++ b/docs/docfile/tutorial/t_robust.rst @@ -1,27 +1,31 @@ .. _robust: -Robust Model -============ - -We provides a series of defense methods that aim to enhance the robustness of GNNs. +Graph Robustness +========================== -Requirements ------------- +Graph robustness is an important research direction in the field of graph representation learning in recent years, +and we have integrated graph robustness-related algorithms in AutoGL, which can be easily used in conjunction with other modules. -During the evaluation, the adversarial attacks on graph are performed by DeepRobust from MSU, please install it by +Preliminaries +----------- +In AutoGL, we divide the algorithms for graph robustness into three categories, which are placed in different modules for implementation. +Robust graph feature engineering aims to generate robust graph features in the data pre-processing phase to enhance the robustness of downstream tasks. +Robust graph neural networks, on the other hand, are designed at the model level to ensure the robustness of the model during the training process. +Robust graph neural network architecture search aims to search for a robust graph neural network architecture. +Each of these three types of graph robustness algorithms will be described in the following sections. -.. code-block:: bash +Robust Graph Feature Engineering +----------- - git clone https://github.com/DSE-MSU/DeepRobust.git - cd DeepRobust - python setup.py install +We provide structure engineering methods to enhance robustness, please refer to `preprocessing` part for more information. -To better plugin GNNGuard to AutoGL, we slightly revised some functions in geometric. Please use the file ``AutoGL/autogl/module/model/pyg/robust/nn/conv/gcn_conv.py`` we provided to replace the corresponding file in the installed geometric folder (for example, the folder path could be `/home/username/.local/lib/python3.5/site-packages/torch_geometric/nn/conv/`). +Robust Model +----------- -*Note:* Don't forget to backup all the original files when you replacing anything, in case you need them at other places! +We provides a series of defense methods that aim to enhance the robustness of GNNs. Building GNNGuard Module ------------------------- +>>>>>>>>>>>>>>>>>>> Firstly, load pre-attacked graph data: @@ -78,3 +82,33 @@ Thirdly, train defense model GNNGuard on poinsed graph: print('=== testing GCN on perturbed graph (AutoGL) + GNNGuard ===') print("acc_test:",test_autogl(modified_adj, features, device, attention=flag)) + +Robust Graph Neural Architecture Search +--------------------------------------- +Robust Graph Neural Architecture Search aims to search for adversarial robust Graph Neural Networks under attacks. +In AutoGL, this module is the code realization of G-RNA. + +Specifically, we design a robust search space for the message-passing mechanism by adding the adjacency mask operations into the search space, +which is inspired by various defensive operators and allows us to search for defensive GNNs. +Furthermore, we define a robustness metric to guide the search procedure, which helps to filter robust architectures. +G-RNA allows us to effectively search for optimal robust GNNs and understand GNN robustness from an architectural perspective. + + +Adjacency Mask Operations +>>>>>>>>>>>>>>>>>>>>>>>>> +Inspired from the success of current defensive approaches, we conclude the properties of operations on graph structure for robustness and +design representative defensive operators in our search space accordingly. +In this way, we can choose the most appropriate defensive strategies when confronting perturbed graphs. +To our best knowledge, this is the first time for the search space to be designed with a specific purpose to enhance the robustness of GNNs. +Specifically, we include five mask operations in the search space. + +- Identity keeps the same adjacency matrix as previous layer +- Low Rank Approximation (LRA) reconstructs the adjacency matrix from the top-k components of singular value decomposition. +- Node Feature Similarity (NFS) deletes edges that have small jaccard similarities among node features. +- Neighbor Importance Estimation (NIE) updates mask values with a pruning strategy base on quantifying the relevance among nodes. +- Variable Power Operator (VPO) forms a variable power graph from the original adjacency matrix weighted by the parameters of influence strengths + +Measuring Robustnes +>>>>>>>>>>>>>>>>>>> +Intuitively, the performance of a robust GNN should not deteriorate too much when confronting various perturbed +graph data. \ No newline at end of file diff --git a/docs/docfile/tutorial_cn/t_robust.rst b/docs/docfile/tutorial_cn/t_robust.rst index b6a98bc..473574d 100644 --- a/docs/docfile/tutorial_cn/t_robust.rst +++ b/docs/docfile/tutorial_cn/t_robust.rst @@ -1,12 +1,33 @@ -.. _robust: +.. _robust_cn: -鲁棒模型 -========================== +图鲁棒性 +============================ + +图鲁棒性是近年图机器学习领域重要的研究方向,我们在AutoGL中集成了图鲁棒性相关算法,可以方便地与其他模块结合使用。 + +背景知识 +------------ + +(介绍对抗攻击、鲁棒问题的定义等,可以适当引一些paper) + +在AutoGL中,我们将图鲁棒性的算法分为三类,放在不同的模块中实现。 +鲁棒图特征工程旨在数据预处理阶段生成鲁棒的图特征,增强下游任务的鲁棒性。 +鲁棒图神经网络则是通过模型层面的设计,以在训练过程中确保模型的鲁棒性。 +鲁棒图神经网络架构搜索旨在搜索出一个鲁棒的图神经网络架构。 +下文中将分别介绍这三类图鲁棒性算法。 + +鲁棒图特征工程 +--------------------- + +我们提供了图结构特征工程的系列方法来提高鲁棒性,请参考`预处理`部分获取更多信息。 + +鲁棒图神经网络 +--------------------- 我们提供了一系列的防御方法,旨在增强图神经网络的鲁棒性。 生成并训练 GNNGuard 模型 ------------------------------- +>>>>>>>>>>>>>>>>>>> 首先,加载预先攻击的图数据: