图神经网络的 Inductive learning 和 Transductive learning

本文最后更新于:2024年3月29日 上午

最近在学图神经网络,发现有两个名词 inductive learningtransductive learning,不太明白这两个有什么区别,收集资料勉强算是搞懂了,在此记录一下。

问题

首先参考【CS224W】Colab 3 第三节 DeepSNAP Advanced 中 Inductive Split 和 Transductive Split 内容,发现他们两个区别是前者是以图为单位,将图分别分到训练集、验证集、测试集,然后后者是以节点为单位,将每个图的节点分别分为训练集、验证集、测试集,不过参考后文,这里有可能是图级别和节点级别的划分方法,与 Inductive learning 和 Transductive learning 无关。

Inductive Split

As what we have learned in the lecture, inductive setting will split multiple graphs into each training/valiation and test sets.

Here is an example of DeepSNAP inductive splitting for a list of graphs in the graph level task (graph classification etc.)

Transductive Split

In transductive setting, the training /validation / test sets are on the same graph.
Here we transductively split the CORA graph in the node level task.
(Notice that in DeepSNAP default setting the split is random, but you can also make a fixed split by specifying fixed_split=True when loading the dataset from PyG or changing the node_label_index directly).

看了一下他们实现的区别是通过dataset.split()函数然后指定transductive=True/False实现,然后我看了一下源码,发现有这么一段话:

1
2
3
4
5
6
7
'''
Args:
transductive (bool): Whether the learning is transductive
(`True`) or inductive (`False`). Inductive split is
always used for the graph-level task, :obj:`self.task`
equals to `graph`.
"""

Inductive split is always used for the graph-level task 看来我的理解有误,这下更懵逼了,难道他们的区别真的只是任务级别的不同???

Inductive learning 和 Transductive learning区别

在网上搜了一下 Inductive learning 和 Transductive learning 的区别,总结一下就是:

Inductive learning 中文意为归纳式学习,它在训练过程中只在训练集上训练,完全不知道测试集的数据内容,模型训练完毕后,将其应用到测试集上,其具有一定的泛化能力。

Transductive learning 中文意为直推式学习,它在训练过程中已经知道测试集的数据,尽管没有标签,但是可以从其特征分布中学到一些额外的信息,可以增加模型的效果,但这意味着有新的样本加入就需要重新训练。

总结二者的区别:

  • 模型训练:Inductive learning 在训练过程中完全不知道测试集信息,而 Transductive learning 在训练过程中已经利用了测试集信息。
  • 模型预测:Transductive learning 只能预测在其训练过程中所用到的样本(Specific --> Specific),而Inductive learning,只要样本特征属于同样的欧拉空间,即可进行预测(Specific --> Gerneral)
  • 模型复用性:当有新样本时,Transductive learning 需要重新进行训练;Inductive Leaning 则不需要。
  • 模型计算量:显而易见,Transductive Leaning 是需要更大的计算量的,即使其有时候确实能够取得相比 Inductive learning 更好的效果。

关于二者的区别,知乎上有一个人的回答很形象:

课后作业里留了期中考试原题的是 transductive learning,不留的是 inductive learning,而且都不给答案。所以有原题的学生成绩更好 狗头保命

图神经网络上的区别

现在勉强理解了,不过新的问题又来了,上面那个源码中为什么 Inductive learning 只能用于图级别的任务?

查阅了很多资料,我怀疑是源码的问题,理论上 Inductive learning 不一定只能用于图级别的任务,不过图神经网络上面的一般区别还是有点不一样的。

图数据和其它数据不同,图数据中每个节点可以通过边的连接来利用其邻域节点的信息,这也就导致了一个问题:如果训练集上的节点通过边关联到了预测集或者验证集的节点,那么在训练的时候能否用它们的信息呢?

Transductive

如果训练时用到了测试集或验证集样本的信息(或者说,测试集和验证集在训练的时候是可见的),那么这种学习方式就叫做 transductive learning。我们经典的图卷积开篇之作中 GCN 使用的就是 Transductive,他在训练的时候输入了整个邻接矩阵的信息,这也就保留了训练集和测试集以及验证集之间的边,聚合了这些节点的特征信息。

Inductive

如果训练时没有用到测试集或验证集样本的信息(或者说,测试集和验证集在训练的时候是不可见的),那么这种学习方式就叫做 Inductive learning。这其中的代表为 GraphSAGE,在具体实现中,训练时它仅仅保留训练样本到训练样本的边,删除了训练样本和测试样本以及验证样本的边。inductive learning 的优点是可以利用已知节点的信息为未知节点生成 Embedding。


图神经网络的 Inductive learning 和 Transductive learning
https://summersong.top/post/c820ed71.html
作者
SummerSong
发布于
2023年8月4日
更新于
2024年3月29日
许可协议