Lecture 4_Extra Graph Neural Networks

Lecture 4_Extra Graph Neural Networks

GNN

Introduction

Neural Network

image-20220919094724476

CNN

image-20220919094805797

https://arxiv.org/pdf/1512.03385.pdf

RNN

image-20220919094856503

Transformer

image-20220919094955677 image-20220919095016287

https://arxiv.org/pdf/1706.03762.pdf

http://speech.ee.ntu.edu.tw/~tlkagk/courses/ML_2019/Lecture/Transformer%20(v5).pdf

Graph

image-20220919095227685

GNN

image-20220919095621412
Why do we need GNN?
Classification
image-20220919095731914

https://persagen.com/files/misc/scarselli2009graph.pdf

训练一个分类器,来识别某一分子是否会导致突变。

Generation
image-20220919095928964

GraphVAE: https://arxiv.org/pdf/1802.03480.pdf

生成新药物的分子。

  • How do we utilize the structures and relationship to help our model?
  • What if the graph is larger, like 20k nodes?
  • What if we don’t have the all the labels?
Example
image-20220919100706953

如上图所示,图中有两种 Node,在一些场景中,Unlabeled Node 的数量远大于 Labeled Node。在这种情况下,如何利用少数的 Labeled Node 以及周围邻居 structure 信息做一个好的 Node Representation,来训练从好的模型呢?

How to train a GNN?
Think about Convolution
image-20220919101553637

如上左图所示,对于绿色和黄色区域,我们可以用 k e r n e l kernel kernel 去做相乘再相加的卷积操作,从而得到下一层的 feature map \text{feature map} feature map。如何把这种操作泛化到 graph 呢?也就是,也能够在 graph 上做相乘相加,再 weighted sum \text{weighted sum} weighted sum 来完成一个类似的 “卷积” 操作。—— 好像不太容易。

  • How to embed node into a feature space using convolution?
    • Solution 1: Generalize the concept of convolution (co-relation) to graph >> Spatial-based convolution
    • Solution 2: Back to the definition of convolution in signal processing >> Spectral-based convolution

GNN Roadmap

image-20220919183803415

Tasks, Dataset, and Benchmark

Tasks

  • Semi-supervised node classification
  • Regression
  • Graph classification
  • Graph representation learning
  • Link prediction

Common Datasets

  • CORA: citation network. 2.7k nodes and 5.4k links
  • TU-MUTAG: 188 molecules with 18 nodes on average

Benchmark

Graph Classification: SuperPixel MNIST and CIFAR10
image-20220921150736197
Regression: ZINC molecule graphs dataset
image-20220921151116552
Node classification: Stochastic Block Model dataset

1711.07553.pdf (arxiv.org)

image-20220921151344912
Edge classification: Traveling Salesman Problem
image-20220921151648821

Results

SuperPixel
image-20220921151944234
Regression
image-20220921152038950
Stochastic Block Model dataset
image-20220921152219323
Traveling Salesman Problem
image-20220921152315076 image-20220921152344872

Spatial-based GNN

Review: Convolution

image-20220919184218595

Spatial-based Convolution

image-20220919184422957

假设 input graph 如上左图所示,图中每个 node 都有一个 hidden feature h i 0 h_i^0 hi0。我们希望通过一个 c o n v o l u t i o n convolution convolution 操作来得到下一层各个 node 的 hidden feature h i 1 h_i^1 hi1。以 h 3 h_3 h3 为例介绍这一过程, h 3 0 h_3^0 h30 3 3 3 个邻居 h 0 0 ,   h 2 0 ,   h 4 0 h_0^0,\ h_2^0,\ h_4^0 h00, h20, h40 h 3 1 h_3^1 h31 将由这 3 3 3 个邻居间的计算得到,这一过程叫做 a g g r e g a t i o n aggregation aggregation,也就是利用邻居的 hidden feature 来得到下一层的 hidden state。

有时候我们需要得到一整个图的表示(而不是只学习各个 node 的 hidden feature),将所有 node 集合起来代表整个 graph 的操作叫做 r e a d o u t readout readout,进而可以做整个图的分类或者预测任务。

NN4G (Neural Networks for Graph)

Neural Network for Graphs: A Contextual Constructive Approach

image-20220919190412189

上图说明了 NN4G 做 a g g r e g a t i o n aggregation aggregation 操作的过程。输入一个 graph,做一个类似于 e m b e d d i n g embedding embedding 的操作( e . g . ,   h 3 0 = w ˉ 0 ⋅ x 3 e.g.,\ h_3^0=\bar w_0 \cdot x_3 e.g., h30=wˉ0x3)得到各 node 的 hidden feature。 a g g r e g a t i o n aggregation aggregation 操作,以 h 3 h_3 h3 为例, h 3 1 = w ^ 1 , 0 ( h 0 0 + h 2 0 + h 4 0 ) + w ˉ 1 ⋅ x 3 h_3^1=\hat w_{1,0}(h_0^0+h_2^0+h_4^0)+\bar w_1 \cdot x_3 h31=w^1,0(h00+h20+h40)+wˉ1x3

image-20220919191027843

上图说明了 NN4G 做 r e a d o u t readout readout 的过程。求各个 hidden layer 的 hidden feature 的均值 X X X,最后做一个 w e i g h t e d   s u m weighted\ sum weighted sum 得到整个图的表示。

DCNN (Diffusion-Convolution Neural Network)

Diffusion-Convolutional Neural Networks (arxiv.org)

image-20220919192518035

上图说明了 DCNN 在各层计算 hidden feature 的做法。输入依旧是一个 graph,以 h 3 h_3 h3 为例。在 hidden layer 1, h 3 0 = w 3 0 M E A N ( d ( 3 , ⋅ ) = 1 ) h_3^0=w_3^0 MEAN(d(3,\cdot)=1) h30=w30MEAN(d(3,)=1),也就是 h 3 0 h_3^0 h30 由所有距离 node_3 长度为 1 1 1 的结点算均值后再 w e i g h t e d   t r a n s f o r m weighted\ transform weighted transform 得到。 h 3 1 h_3^1 h31 也类似可得,只是考虑所有距离 node_3 长度为 2 2 2 的结点。

如下图所示,将每层 hidden layer 中的 hidden feature 拼接成一个矩阵 H \bf H H,将这些矩阵 H \bf H H 堆叠起来。如果需要做 Node Classification 的任务,我们只需要取特定的一个 s l i c e slice slice 就能够获得该 node 在各层的 hidden feature,再通过 w e i g h t e d   t r a n s f o r m weighted\ transform weighted transform 得到预测的标签。

image-20220919193953985

DGC (Diffusion Graph Convolution)

1707.01926.pdf (arxiv.org) Published as a conference paper in ICLR 2018.

image-20220919194238113

这篇文章没有将矩阵 H \bf H H 堆叠起来,而是将各层的矩阵 H \bf H H 进行相加。

MoNET (Mixture Model Networks)

1611.08402.pdf (arxiv.org)

image-20220919195039809

如上图所示,MoNET 设计了一个新的结点间的距离函数: u = ( 1 d e g ( x ) ,   1 d e g ( y ) ) T {\bf u}={(\frac{1}{\sqrt {deg(x)}},\ \frac{1}{\sqrt {deg(y)}})}^{\rm T} u=(deg(x) 1, deg(y) 1)T,度量结点间的距离与两结点的有关。更新 hidden feature 的方式依旧是对邻居结点做 w e i g h t e d   s u m weighted\ sum weighted sum

GraphSAGE

1706.02216.pdf (arxiv.org)

image-20220919195611009

GraphSAGE 做 a g g r e g a t i o n aggregation aggregation 的方式有三种: m e a n ,   p o o l i n g ,   L S T M mean,\ pooling,\ LSTM mean, pooling, LSTM

image-20220919195645261

GAT (Graph Attention Networks)

1710.10903.pdf (arxiv.org) Published as a conference paper at ICLR 2018.

image-20220919200208610 image-20220919200400306

如上图所示,是 GAT 更新 hidden feature 的做法。首先,计算待更新结点 h 3 0 h_3^0 h30 与其邻居结点的 e n e r g y energy energy e 3 , i e_{3,i} e3,i,从而 h 3 1 = e 3 , 0 ⋅ h 0 0 + e 3 , 2 ⋅ h 2 0 + e 3 , 4 ⋅ h 4 0 h_3^1=e_{3,0}\cdot h_0^0+e_{3,2}\cdot h_2^0+e_{3,4}\cdot h_4^0 h31=e3,0h00+e3,2h20+e3,4h40,相当于 a g g r e g a t i o n aggregation aggregation 操作中的 w e i g h t e d   s u m weighted\ sum weighted sum 需要学习其中的权重。

GIN (Graph Isomorphism Network)

image-20220919201337089 image-20220919201538265

Graph Signal Processing and Spectral-based GNN

Spectral-based CNN

image-20220920115405844

对输入、Filter 和 每层的 graph 都做 fourier transform \text{fourier transform} fourier transform 以达到类似于卷积的效果。

Spectral Graph Theory

image-20220920144831442 image-20220920145241305 image-20220920151404016
Example
image-20220920145218795
Vertex domain signal

注:由于本人没有学过《信号与系统》,所以以下的内容可能会存在许多错误。(希望有大佬能指出)

image-20220920145607625

如上图所示,graph 中各个 node 的信号大小由 f f f 给出。那么我们可以得到该 graph 的 adjacency matrix A \bf A A,degree matrix D \bf D D,进而得到 Laplacian L = D − A \bf L=D-A L=DA(一个半正定 positive semidefinite 矩阵),继续算出 L \bf L L 的特征值(频率 frequency)矩阵 Λ \bf \Lambda Λ 及特征向量组成的矩阵 U \bf U U

image-20220920150700471 image-20220920151004963

如上图所示,当频率(特征值)分别取 0 ,   1 ,   3 ,   4 0,\ 1,\ 3,\ 4 0, 1, 3, 4 时,各结点的信号强度(用橘黄色标出)。

接下来,我们来尝试理解 vertex frequency:

image-20220920152035431

① 我们可以把 Laplacian L = D − A \bf L=D-A L=DA 看作作用在图上的一个算子;

② 给定图中的信号 f f f L f {\bf L}f Lf 代表着什么呢?

③ 简单的数学变换, L f = ( D − A ) f = D f − A f {\bf L}f=({\bf D-A})f={\bf D}f-{\bf A}f Lf=(DA)f=DfAf

④ 分别写出各结点的 degree matrix D \bf D D,adjacency matrix A \bf A A,假设 f = [ 4 , 2 , 4 , − 3 ] T ,   L f = [ a , b , c , d ] T f={[4,2,4,-3]}^{\rm T},\ {\bf L}f={[a,b,c,d]}^{\rm T} f=[4,2,4,3]T, Lf=[a,b,c,d]T

⑤ 关注 L f {\bf L}f Lf 的第一行,每个蓝圈圈出的数字,其含义如图所示。可以理解成度量某一信号跟他旁边结点的能量差异。

如下图所示,度量信号间能量的差异往往需要将这一差值取平方,进而可以进一步理解为度量图中信号的平滑程度。由 [Spectral Graph Theory](#Spectral Graph Theory),频率越大,相邻两点之间的信号变化量就越大。 f T L f f^{\rm T}{\bf L}f fTLf 代表了不同结点间信号变化量的能量。

image-20220921100743787

用 Laplacian L \bf L L 的特征向量替代 f f f,不难得到下图中的结果。

image-20220921101647465

如下图所示,我们想要将 vertex domain 的信号转换到 spectral domain 的信号:

① 类比传统信号与系统中的问题,将方法迁移到我们的问题上来;

② 通过对信号 x x x 的处理: x ^ = U T x \hat x={\bf U}^{\rm T}x x^=UTx,我们可以得到原信号在 spectral domain 的表示,也就是下图中 ③ 这一过程;

④ 那么,如何将 spectral domain 的信号转换到 vertex domain 上呢?依旧类比传统信号与系统中的问题,即下图中 ⑤ 这个过程。

image-20220921105222117

过程 ⑤ 如下图所示:

image-20220921110533806

将过程 ⑤ 拓展到 graph 上,通过对 spectral domain 上的 x ^ \hat x x^ 进行 x = U x ^ x={\bf U}\hat x x=Ux^ 的变换可以完成 spectral domain 到 vertex domain 的信号转换。

image-20220921110946985
Filtering

类比传统信号与系统中的问题,对信号进行 Filter —— 乘上一个频率响应的矩阵 g θ {\bf g}_\theta gθ

image-20220921112839065

给定输入 x x x,希望模型能够学习到一个 f i l t e r   g θ filter\ {\bf g}_\theta filter gθ,输出 y y y,类似于卷积操作。

这个模型存在问题,① 学习 g θ {\bf g}_\theta gθ 的复杂度是 O ( N ) O(N) O(N);② 会学习到不应该学习的东西,没有局部化(类比卷积中的 R e c e p t i v e   f i e l d Receptive\ field Receptive field,仅对感受野中的数值进行操作,是局部化的操作)。

image-20220921113711550

问题 ② 体现在:

image-20220921115028839

ChebNet

1606.09375.pdf (arxiv.org)

g θ {\bf g}_\theta gθ 做出了限制。

image-20220921120204564 image-20220921120358876

GCN

image-20220921150338993 image-20220921150358022
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值