SimGRACE: A Simple Framework for Graph Contrastive Learning without Data Augmentation

https://arxiv.org/pdf/2202.03104

https://github.com/junxia97/simgrace

SimGRACE: A Simple Framework for Graph Contrastive Learning without Data Augmentation,2022,WWW

1. 简介

1.1 摘要

Graph contrastive learning (GCL) has emerged as a dominant technique for graph representation learning which maximizes the mutual information between paired graph augmentations that share the same semantics. Unfortunately, it is difficult to preserve semantics well during augmentations in view of the diverse nature of graph data. Currently, data augmentations in GCL that are designed to preserve semantics broadly fall into three unsatisfactory ways. First, the augmentations can be manually picked per dataset by trial-and-errors. Second, the augmentations can be selected via cumber some search. Third, the augmentations can be obtained by introducing expensive domain-specific knowledge as guidance. All of these limit the efficiency and more general applicability of existing GCL methods. To circumvent these crucial issues, we propose a Simple framework for GRAph Contrastive lEarning, SimGRACE for brevity, which does not require data augmentations. Specifically, we take original graph as input and GNN model with its perturbed version as two encoders to obtain two correlated views for contrast. SimGRACE is inspired by the observation that graph data can preserve their semantics well during encoder perturbations while not requiring manual trial-and-errors, cumbersome search or expensive domain knowledge for augmentations selection. Also, we explain why SimGRACE can succeed. Furthermore, we devise adversarial training scheme, dubbed AT-SimGRACE, to enhance the robustness of graph contrastive learning and theoretically explain the reasons. Albeit simple, we show that SimGRACE can yield competitive or better performance compared with state-of-the-art methods in terms of generalizability, transferability and robustness, while enjoying unprecedented degree of flexibility and efficiency.

图对比学习最近成了图表示学习的主流方法之一,通过最大化两个共享相同语义信息的增强视角之间的互信息来学习节点嵌入。不幸的是,考虑到图数据存在天然的差异性,因此在图增强过程中很难保留语义信息。目前,GCL中的数据增强策略的选取方式主要有3种类型:第1种是通过人工进行试错式选取。第2种,通过繁琐的搜索来寻找最适合的增强策略。第3种是通过引入大量领域相关知识作为指导来选取。这些方法都限制了现有GCL方法的有效性和通用性。为了解决这个问题,我们提出了SimGRACE,一个不需要数据增强的GCL框架。具体来说,将原始图作为输入,GNN模型的2个perturbed版本作为两个编码器,用来获得两个视角进行对比。SIMGRACE的ideal来自于: the observation that graph data can preserve their semantics well during encoder perturbations,从而避免了前面提到的3种缺陷。当然,我们解释了为什么SIMGRACE能取得成功。另外,我们设计了对抗训练模式AT-SIMGRACE,来提高图对比学习的鲁棒性,并从理论上进行了解释。尽管方法简单,和SOTA方法相比,我们发现SimGRACE无论是性能、鲁棒性还是迁移能力都具有竞争力或更好表现,同时效率和灵活性都更高。

1.2 本文工作

背景: 现有GCL方法对于增强策略的选取方式主要有3种:人工选择、grid search或者引入领域相关信息作为指导。这些方式限制了GCL方法的性能和通用性。

注:这里作者说的不准,很多自适应增强或者自动增强方法,没有提到。(可能可以糊弄下大同行)

动机: 图增强的核心在于:在保留原始图语义信息的前提下,生成两个具有一定差异的增强视角。作者的ideal来自于:the observation that graph data can preserve their semantics well during encoder perturbations。那为什么不直接去掉图增强,用两个pertubated graph encoder的输出作为对比对象呢?(方法很讨巧)

本文工作: 1. 首先,作者提出了SimGRACE,一种不需要图增强的GCL框架,并给出理论解释;2. 其次,还设计了一个对抗训练版本AT-SimGRACE,进一步提高模型鲁棒性,并给出了理论解释。

2. 方法

模型细节

  1. Encoder perturbation

    f(;θ)f(\cdot;\theta)表示GNN编码器,f(;θ)f(\cdot;\theta')表示其扰动版本,hhhh'表示两个编码器学习到的节点嵌入。扰动编码器参数计算方式如下:

    θl=θl+ηΔθl;ΔθlN(0,σl2)\theta_{l}^{\prime}=\theta_{l}+\eta \cdot \Delta \theta_{l} ; \quad \Delta \theta_{l} \sim \mathcal{N}\left(0, \sigma_{l}^{2}\right)

    其实就是将原始GNN每一层的参数加上一个高斯噪声。

  2. Projection head

    这个属于常规操作,将节点嵌入用一个非线性函数映射到对比空间。

    z=g( h),z=g( h)z=g(\mathrm{~h}), z^{\prime}=g\left(\mathrm{~h}^{\prime}\right)

  3. Contrastive loss

    这个也很常规,和其他GCL方法没什么区别:

    n=logexp(sim(zn,zn))/τ)n=1,nnNexp(sim(zn,zn)/τ)\ell_{n}=-\log \frac{\left.\exp \left(\operatorname{sim}\left(z_{n}, z_{n}^{\prime}\right)\right) / \tau\right)}{\sum_{n^{\prime}=1, n^{\prime} \neq n}^{N} \exp \left(\operatorname{sim}\left(z_{n}, z_{n^{\prime}}\right) / \tau\right)}

理论证明

作者基于“ Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere”这篇文章,尝试解释SIMGRACE为什么有效。在这篇文章里,作者给出了两个评价对比学习获取到的节点嵌入质量的指标:alignment和uniformity。

  • alignment:正样本对之间的距离

    align (f;α)E(x,y)ppos [f(x)f(y)2α],α>0\ell_{\text {align }}(f ; \alpha) \triangleq \underset{(x, y) \sim p_{\text {pos }}}{\mathbb{E}}\left[\|f(x)-f(y)\|_{2}^{\alpha}\right], \quad \alpha>0

    其中pposp_{pos}表示所有的正样本对。这个指标其实适合对比学习的目标相对应的,即正样本在嵌入空间中的距离应该很近。

    在SimGRACE里面,alignment计算方式可以转换成:

    align (f;α)Expdata [f(x;θ)f(x;θ)2α],α>0\ell_{\text {align }}(f ; \alpha) \triangleq \mathbb{E}_{x \sim p_{\text {data }}}\left[\left\|f(x ; \theta)-f\left(x ; \theta^{\prime}\right)\right\|_{2}^{\alpha}\right], \quad \alpha>0

    其中pdatap_{data}表示数据分布,其实就是输入图的所有节点。

  • uniform: the logarithm
    of the average pairwise Gaussian potential

    uniform (f;α)logEx,yi.i.d.pdata [etf(x;θ)f(y;θ)22]\ell_{\text {uniform }}(f ; \alpha) \triangleq \log \underset{x, y^{i . i . d .} p_{\text {data }}}{\mathbb{E}}\left[e^{-t\|f(x ; \theta)-f(y ; \theta)\|_{2}^{2}}\right]

    uniform对应于对比学习的另一个目标:随机样本的嵌入应该分散在嵌入空间中。

作者在训练过程中每2个epochs,记录下lalignl_{align}luniforml_{uniform}值。作者对比了SimGRACE、GraphCL和MoCL三种方法,如下图所示:

从上图可以看出,GraphCL的alignment和uniformity值要大于SimGRACE和MoCL,这说明他不能让正样本对保持比较近的距离(因为图增强破坏了原始图的语义信息)。相反,MoCL通过引入领域知识作为指导来选取增强策略,可以在增强过程中保留语义信息,因此alignment指标下,表现较好。但是在uniformity指标下,其表现不如SimGRACE,因此最终的表现也不如SimGRACE。

AT-SimGRACE

在GraphCL中,其作者提到过它们的框架能够提高模型鲁棒性,但是并没有进行解释。这里作者希望利用对抗训练提升SimGRACE的对抗攻击鲁棒性。

一个通用的AT框架公式如下:

minθL(θ), where L(θ)=1ni=1nmaxxixipϵi(f(xi;θ),yi)\min _{\theta} \mathcal{L}^{\prime}(\theta), \quad \text { where } \quad \mathcal{L}^{\prime}(\theta)=\frac{1}{n} \sum_{i=1}^{n} \max _{\|\mathrm{x}_{i}^{\prime}-\mathbf{x}_{i} \|_{p} \leq \epsilon} \ell_{i}^{\prime}\left(f\left(\mathrm{x}_{i}^{\prime} ; \theta\right), y_{i}\right) \text {, }

但是这个框架不能直接用于GCL,存在以下问题:

  1. AT需要标签信息,但是GCL中没有
  2. 对数据集中的每个图都进行perturbation,计算量过大,这个问题在GROC已经被指出。

为了解决第一个问题,作者用对比损失代替监督分类中的交叉熵损失。

为了解决第2个问题,作者对encoder进行对抗扰动,而不是图数据。具体来说,假设Θ\Theta表示GNNs的权重空间,对于任意的ww和任意正数ϵ\epsilon,可定义如下norm ball:

R(w;ϵ):={θΘ:θwϵ}\mathrm{R}(\mathrm{w} ; \epsilon):=\{\theta \in \Theta:\|\theta-\mathrm{w}\| \leq \epsilon\}

这样AT-SimGRACE的优化目标定义为:

minθL(θ+Δ)where L(θ+Δ)=1Mi=1MmaxΔR(0;ϵ)i(f(Gi;θ+Δ),f(Gi;θ))\min _{\theta} \mathcal{L}(\theta+\Delta) \text {, } \\ where\ \mathcal{L}(\theta+\Delta)=\frac{1}{M} \sum_{i=1}^{M} \max _{\Delta \in \mathrm{R}(0 ; \epsilon)} \ell_{i}\left(f\left(\mathcal{G}_{i} ; \theta+\Delta\right), f\left(\mathcal{G}_{i} ; \theta\right)\right)

理论证明

基础1:大部分人都认同“flatter loss landscape can bring robustness”。

因此要证明AT-SimGRACE能提高鲁棒性,只需要证明它能带来跟平滑的loss变化即可。

基础:2:已经有工作证明了loss landscape和PAC-Bayes之间存在关联。

E{Gi}i=1M,Δ[L(θ+Δ)]EΔ[L(θ+Δ)]+4KL(θ+ΔP)+ln2MδM\mathbb{E}_{\left\{\mathcal{G}_{i}\right\}_{i=1}^{M}, \Delta}[\mathcal{L}(\theta+\Delta)] \leq \mathbb{E}_{\Delta}[\mathcal{L}(\theta+\Delta)]+4 \sqrt{\frac{K L(\theta+\Delta \| P)+\ln \frac{2 M}{\delta}}{M}}

E{Gi}i=1M,Δ[L(θ+Δ)]L(θ)+{EΔ[L(θ+Δ)]L(θ)}Expected sharpness +41M(12α+ln2Mδ)\begin{aligned} \mathbb{E}_{\left\{\mathcal{G}_{i}\right\}_{i=1}^{M}, \Delta}[\mathcal{L}(\theta+\Delta)] \leq \mathcal{L}(\theta) &+\underbrace{\left\{\mathbb{E}_{\Delta}[\mathcal{L}(\theta+\Delta)]-\mathcal{L}(\theta)\right\}}_{\text {Expected sharpness }} \\ &+4 \sqrt{\frac{1}{M}\left(\frac{1}{2 \alpha}+\ln \frac{2 M}{\delta}\right)} \end{aligned}

最终得出一个结论:AT-SimGRACE可以优化sharpness of loss landscape的最差情况,即减小maxΔ[L(θ+Δ)]L(θ)max_\Delta[L(\theta+\Delta)]-L(\theta)的上界。

这块涉及到的数学公式,我也不太懂,可以大概了解下作者的证明思路:首先把鲁棒性问题转化成loss平滑性,然后用PAC-Bayes框架算出AT-SimGRACE的loss平滑性优于原来的。

实验

主要关注5个问题:

  1. 通用性:无监督、半监督设定下,模型在下游任务的表现是否优于竞争对手?

2. 迁移性:预训练模式下的Sim-GRACE是否优于竞争对手?
  1. 鲁棒性:Sim-GRACE在不同对抗攻击下是否优于竞争对手?

  2. 性能:时间、空间占用情况是否优于对手?

  3. 超参敏感性:扰动参数、epoch和batch大小等等。

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2021-2022 Yin Peng
  • 引擎: Hexo   |  主题:修改自 Ayer
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信