第十周.01.SGCN


本文内容整理自深度之眼《GNN核心能力培养计划》
公式输入请参考: 在线Latex公式
本周主要是讲解GNN简化模型,这个研究方向不是在模型的精度上进行提高,而是把精力放在模型的简化,使得模型精度在不大幅下降的前提下,计算更加简单,模型能处理更加大的数据集。
涉及到的模型有三个:SGCN、 FastGCNLight GCN
这节只讲第一个。
Simplifying Graph Convolutional Networks

GCN回顾

以下观点来自:Deeper insights into graph convolutional networks for semi-supervised learning
GCN model is simply a special form of Laplacian smoothing, which mixes the features of a vertex and its nearby neighbors.
GCN的拉普拉斯平滑的一种特殊形式:将一跳邻居特征进行平均后传播(对应公式AX)
The features of vertices in the same cluster similar, thus greatly easing the classification task.
经过2-3次图卷积操作,相邻的节点的embedding相似性会进一步加强,这有利于下游的节点分类任务。
Deep GCN may have oversmoothed issues and vertices from different clusters may become indistinguishable.
随着图卷积次数增加,会出现过拟合(过平滑)现象,会导致节点embedding趋于一致不利于分类。
The authors compare them with the simplest fully-connected networks (FCNs), Clearly the graph convolution is the key to the huge performance gain.
实验方式就是将一跳邻居特征进行平均后传播这个步骤取消,直接将输入节点的特征X接入FC,大家可以思考这样做的结果是什么

SGCN

题目:Simplifying Graph Convolutional Networks
代码
作者:Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr., Christopher Fifty, Tao Yu, Kilian Q. Weinberger

摘要

这里有个de facto,是【实际上】的意思。
第一句先讲GCN的变种对于图表示学习非常重要。
Graph Convolutional Networks (GCNs) and their variants have experienced significant attention and
have become the de facto methods for learning graph representations.

内含转折提出目前GCN存在的问题:unnecessary complexity and redundant computation
GCNs derive inspiration primarily from recent deep learning approaches, and as a result, may inherit unnecessary complexity and redundant computation.

本文提出如何解决上面提出的问题
In this paper, we reduce this excess complexity through successively removing nonlinearities and collapsing weight matrices between consecutive layers.

理论上还证明了一波
We theoretically analyze the resulting linear model and show that it corresponds to a fixed low-pass filter followed by a linear classifier.

最后就是实验表明了什么,模型能用在什么方面。
Notably, our experimental evaluation demonstrates that these simplifications do not negatively impact accuracy in many downstream applications. Moreover, the resulting model scales to larger datasets, is naturally interpretable, and yields up to two orders of magnitude speedup over FastGCN.

Introduction

最重要就是这句话:
We reduce the excess complexity of GCNs by repeatedly removing the nonlinearities between GCN layers and collapsing the resulting function into a single linear transformation.
1.将多次的图卷积整合到一起(下图中间长方形框内的东西)
2.去掉了非线性的ReLU(相当于将高维直接通过逻辑回归变低维,具体看下图右边彩色的下面的公式)
论文的图1:
在这里插入图片描述

Simple Graph Convolution(模型介绍)

重点看原文2.2节,如何从原始GCN简化到SGCN的

模型的notation

图: G = ( V , A ) \mathcal{G}=(\mathcal{V},A) G=(V,A)
注意,这里不是平常的 G = ( V , E ) \mathcal{G}=(\mathcal{V,E}) G=(V,E)
其中 V \mathcal{V} V当然是图的 n n n个节点: { v 1 , ⋯   , v n } \{v_1,\cdots,v_n\} {v1,,vn}
A ∈ R n × n A\in \mathbb{R}^{n\times n} ARn×n是图的邻接矩阵,矩阵是对称的,而且矩阵里面的元素 a i j a_{ij} aij表示的是边的权重。两个节点如果没有边当然是 a i j = 0 a_{ij}=0 aij=0
D = d i a g ( d 1 , ⋯   , d n ) D= diag(d_1,\cdots,d_n) D=diag(d1,,dn)是图的度矩阵
X ∈ R n × d X\in \mathbb{R}^{n\times d} XRn×d是图中节点的向量表示, n n n个节点,每个节点是 d d d维向量,分成每个节点的向量就是: X = [ x 1 , ⋯   , x n ] ⊤ X=[x_1,\cdots,x_n]^\top X=[x1,,xn]
每个节点属于一个分类,共有C个分类,因此每个节点的分类标签 y i y_i yi可以用C维的独热编码表示。
数据集中我们只有部分数据的标签,要对未知的节点做预测。

2.1 GCN

H ( k ) \textbf{H}^{(k)} H(k)表示第k层卷积的输出的每个节点embedding,它是由 H ( k − 1 ) \textbf{H}^{(k-1)} H(k1)经过卷积得到的,当然,第一层的输入 H ( 0 ) = X \textbf{H}^{(0)}=X H(0)=X
一个K层的GCN相当于与K层的MLP,但MLP每层都会对节点进行拉普拉斯平滑(在GCN里面就是feature propagation)。
GCN的卷积层包含三个操作,可以在图1中的长方形中找到: feature propagation, linear transformation, and a pointwise nonlinear activation.
这里讨论feature propagation的时候,给出的公式2(拉普拉斯平滑)和公式3(GCN的形式)是有联系的,两个公式都是表示每一层的节点 v i v_i vi的特征表示 h i h_i hi都是节点 v i v_i vi一跳邻居(local neighborhood average)的前一层特征表示的平均值:
h ˉ i ( k ) ← 1 d i + 1 h i ( k − 1 ) + ∑ j = 1 n a i j ( d i + 1 ) ( d j + 1 ) h j ( k − 1 ) (2) \bar h_i^{(k)}\leftarrow\cfrac{1}{d_i+1}h_i^{(k-1)}+\sum_{j=1}^n\cfrac{a_{ij}}{\sqrt{(d_i+1)(d_j+1)}}h_j^{(k-1)}\tag2 hˉi(k)di+11hi(k1)+j=1n(di+1)(dj+1) aijhj(k1)(2)
这里的后面一项的分母是邻接矩阵的元素,因此整个后面一项除了当前节点 v i v_i vi的邻居之外都是0。
所以求和也可以写成 ∑ j ∈ v i n e i g b o r s \sum_{j \in v_{i_{neigbors}}} jvineigbors
写成矩阵形式:
S = D ~ − 1 2 A ~ D ~ − 1 2 (3) \textbf{S}=\tilde\textbf{D}^{-\frac{1}{2}}\tilde\textbf{A}\tilde\textbf{D}^{-\frac{1}{2}}\tag3 S=D~21A~D~21(3)
两个公式中, d i + 1 d_i+1 di+1的1相当于 A ~ = A + I \tilde\textbf{A}=\textbf{A}+\textbf{I} A~=A+I中的 I \textbf{I} I,也就是原文中的self-loops。 D ~ \tilde\textbf{D} D~ A ~ \tilde\textbf{A} A~的邻接矩阵。
公式2中的后面一项的分子的两个根号对应公式3中的负二分之一次方。
整个公式3得到的结果就是经过归一化的邻接矩阵(带self-loops)(原文归一化带引号,实际上并没有归一化)。
然后进行:
H ˉ ( k ) = S H ( k − 1 ) (4) \bar\textbf{H}^{(k)}=\textbf{S}\textbf{H}^{(k-1)}\tag4 Hˉ(k)=SH(k1)(4)
这个就是GCN比MLP多的步骤,有了这个步骤会怎么样??
this step smoothes the hidden representations locally along the edges of the graph and ultimately encourages similar predictions among locally connected nodes.
完成上面的步骤后,GCN的操作和MLP是一样的,每一个层对应一个可学习的权重矩阵 Θ ( k ) \Theta^{(k)} Θ(k)
H ( k ) ← ReLU ( H ˉ ( k ) Θ ( k ) ) (5) \textbf{H}^{(k)}\leftarrow\text{ReLU}\left(\bar\textbf{H}^{(k)}\Theta^{(k)}\right)\tag5 H(k)ReLU(Hˉ(k)Θ(k))(5)
最后是用softmax进行分类,一个K层的GCN的节点的类别预测可以写为:
Y ^ G C N = softmax ( S H ( K − 1 ) Θ ( K ) ) (6) \hat\textbf{Y}_{GCN}=\text{softmax}\left(\textbf{S}\textbf{H}^{(K-1)}\Theta^{(K)}\right)\tag6 Y^GCN=softmax(SH(K1)Θ(K))(6)
这里重点掌握GCN的新的表达和理解。

2.2 SGC

先简化非线性变化ReLU(为什么能去掉?这个其实在Deeper insights into GCN里面有实验,这里先当做假设来弄的,做这样的假设是因为文章分析了,整个GCN里面重要的是拉普拉斯平滑,就是local neighborhood average,非线性变化不重要),去掉后:
Y ^ = softmax ( S ⋯ S SX Θ ( 1 ) ‾ Θ ( 2 ) ‾ ⋯ Θ ( K ) ) (7) \hat Y = \text{softmax}\left(\textbf{S}\cdots\underline{\textbf{S}\underline{\textbf{S}\textbf{X}\Theta^{(1)}}\Theta^{(2)}}\cdots\Theta^{(K)}\right)\tag7 Y^=softmax(SSSXΘ(1)Θ(2)Θ(K))(7)
这里为了看清楚,我加了下划线,第一个下划线 SX Θ ( 1 ) \textbf{S}\textbf{X}\Theta^{(1)} SXΘ(1),由于 H ( 0 ) = X \textbf{H}^{(0)}=\textbf{X} H(0)=X,实际上是:
H ( 1 ) = S H ( 0 ) Θ ( 1 ) \textbf{H}^{(1)}=\textbf{S}\textbf{H}^{(0)}\Theta^{(1)} H(1)=SH(0)Θ(1)
上面公式7的第一个下划线就写成:
Y ^ = softmax ( S ⋯ S H ( 1 ) Θ ( 2 ) ‾ ⋯ Θ ( K ) ) \hat Y = \text{softmax}\left(\textbf{S}\cdots\underline{\textbf{S}\textbf{H}^{(1)}\Theta^{(2)}}\cdots\Theta^{(K)}\right) Y^=softmax(SSH(1)Θ(2)Θ(K))
依次玩K-1次就是去掉了ReLU的GCN,公式7可以简写为:
Y ^ S G C = softmax ( S K X Θ ) (8) \hat Y_{SGC} =\text{softmax} \left(\textbf{S}^K\textbf{X}\Theta\right)\tag8 Y^SGC=softmax(SKXΘ)(8)
公式8就叫做Simple Graph Convolution (SGC)
然后原文从逻辑回归和凸优化的两个方面谈了一下这个公式8是怎么简单的,简单在哪里?

谱域分析

这节不展开,把第一段翻译一下吧。
这节中从图卷积的角度来研究SGC。
We now study SGC from a graph convolution perspective.
证明了SGC在谱域上对应一个固定的滤波器。
We demonstrate that SGC corresponds to a fixed filter on the graph spectral domain.
证明了在原始图上添加自循环,例如:renormalization trick,可以有效地缩小底层图的谱。
In addition, we show that adding self-loops to the original graph, i.e. the renormalization trick
(Kipf & Welling, 2017这里是GCN半监督的文章,里面有详细的谱域推导), effectively shrinks the underlying graph spectrum.
在这个谱域中,SGC作为一个低通滤波器,在图上生成平滑的特征。因此,邻居节点倾向于共享/生成相似的表示。
On this scaled domain, SGC acts as a lowpass filter that produces smooth features over the graph. As a result, nearby nodes tend to share similar representations and consequently predictions.

实验(略)

DGL源码分析

https://docs.dgl.ai/_modules/dgl/nn/pytorch/conv/sgconv.html
看主要的部分,就是对应公式那块,在forward函数里面,函数有两个参数,一个是图结构graph,一个是节点特征feat

# compute normalization
                degs = graph.in_degrees().float().clamp(min=1)#从graph读取所有节点的度矩阵D,并设置度最小为1
                norm = th.pow(degs, -0.5)#D的负二分之一次方
                norm = norm.to(feat.device).unsqueeze(1)#D第二维增加一个维度
                # compute (D^-1 A^k D)^k X
                for _ in range(self._k):#按层数做拉普拉斯平滑
                    feat = feat * norm
                    graph.ndata['h'] = feat#节点特征放ndata
                    graph.update_all(fn.copy_u('h', 'm'),
                                     fn.sum('m', 'h'))#从源节点copy特征,并将它们聚合到目标节点中。
                    feat = graph.ndata.pop('h')
                    feat = feat * norm
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

oldmao_2000

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值