Part V · 第 17 章 网络架构 · 17.4Part V · Ch. 17 Network Architectures · 17.4

图神经网络 (Graph Neural Networks)Graph Neural Networks

机器人的世界由“东西和它们之间的关系”组成:绳子是一串由弹簧连着的质点,腿足机器人是由关节连着的连杆,桌面场景是物体和“在……上面”的关系,多机器人队伍是由无线链路连着的机器人。图神经网络直接把这张图当作输入:在每个节点和每条边上反复运行同一个小网络,让相邻的东西互相传递消息。所以它对任意数量的节点都适用,不在乎节点怎样编号,还能学会物理:本节就在浏览器里现场训练一个绳子与布料的模拟器。 A robot's world is made of things and the relations between them: a rope is a chain of masses joined by springs, a legged robot is links joined by joints, a tabletop is objects with relations such as "on top of", and a team of robots is robots joined by radio links. A graph neural network takes that graph itself as its input: it runs the same small network on every node and every edge, again and again, so that neighbouring things pass messages to each other. It therefore works for any number of nodes, does not care how the nodes are numbered, and can learn physics: in this lesson you will train a rope-and-cloth simulator live in your browser.

约 40 分钟~40 min 前置:17.1 MLP 与 CNN · 17.3 Transformer 与 Attention · 16.3 反向传播Prereqs: 17.1 MLPs & CNNs · 17.3 Transformers & Attention · 16.3 Backpropagation 6 个交互6 interactives

    1为什么机器人需要它Why robots need this

    前面几节的网络各自假设了输入的“形状”。MLP 要一个长度固定、顺序固定的向量;CNN 要规则的像素网格;Transformer 要一串 token,并让每个 token 都能看到所有其他 token。可机器人遇到的很多数据是另一种形状:

    • 可变形物体:绳子、布料、面团可以看成许多质点(或网格顶点),相邻的质点之间有力。
    • 机器人本体:连杆和关节组成一棵树(7.1 节);四足、六足和蛇形机器人的树长得不一样。
    • 场景:物体和它们之间的关系(“杯子在桌上”),也就是 15.3 节讲的三维场景图。
    • 多机器人:每台机器人只能和通信范围内的邻居交换信息。
    • 点云:激光雷达的点和它附近的点(12.1 节)。

    这些数据有三个共同点:东西的数量会变(6 段绳子还是 12 段,4 条腿还是 6 条);东西的编号是随意的(谁是 1 号质点不影响物理);相互作用主要是局部的(一个质点只被和它相连的弹簧拉)。把它们拼成一个长向量喂给 MLP,这三点全都违反了:换个大小网络就要重训,换个编号输出就变,而且网络得从数据里自己猜出谁和谁相连。

    图神经网络(GNN)把图本身当作输入。它在每条边上运行同一个“消息函数”,在每个节点上运行同一个“更新函数”,重复几轮。这样得到的网络对任意大小的图都能用,对节点编号天然不敏感,而且只让相连的东西直接对话。本节先看消息传递在做什么(FIG 1),再现场训练一个学出来的绳子模拟器(FIG 2),然后看置换等变性、图注意力 GAT、Transformer 与 GNN 的关系,以及层数太多时的“过平滑”。

    Each network in the previous lessons assumed a "shape" for its input. An MLP wants a vector of fixed length in a fixed order; a CNN wants a regular grid of pixels; a transformer wants a sequence of tokens and lets every token see every other token. Much of what a robot deals with has a different shape:

    • Deformable objects: a rope, a cloth or a lump of dough can be seen as many point masses (or mesh vertices) with forces between neighbouring ones.
    • Robot bodies: links and joints form a tree (Lesson 7.1), and the trees of a quadruped, a hexapod and a snake robot all differ.
    • Scenes: objects and the relations between them ("the cup is on the table"), the 3D scene graphs of Lesson 15.3.
    • Multi-robot teams: each robot can only exchange information with the neighbours within radio range.
    • Point clouds: lidar points and the points near them (Lesson 12.1).

    Three things are common to all of them: the number of things varies (a rope of 6 segments or 12, four legs or six); the numbering is arbitrary (which mass is called number 1 changes nothing physical); and interactions are mostly local (a mass is pulled only by the springs attached to it). Concatenating everything into one long vector for an MLP breaks all three: a different size means retraining, a different numbering changes the output, and the network has to guess from data who is connected to whom.

    A graph neural network (GNN) takes the graph itself as input. It runs one shared "message function" on every edge and one shared "update function" on every node, for a few rounds. The result works on graphs of any size, is insensitive to the numbering by construction, and lets only connected things talk directly. This lesson first shows what message passing does (FIG 1), then trains a learned rope simulator live (FIG 2), and then looks at permutation equivariance, graph attention (GAT), how transformers relate to GNNs, and the "oversmoothing" that appears with too many layers.

    2直觉:每一层,节点和邻居说一次话Intuition: every layer, each node talks to its neighbours once

    每个节点 \(i\) 带一个特征向量 \(\mathbf h_i\)(对绳子是质点的速度,对机器人是关节角,对物体是它的类别和位置)。GNN 的一层做三件事:

    1. 发消息:每条边 \(j\to i\) 用同一个小网络 \(\phi\) 算出一条消息 \(\mathbf m_{ij}=\phi(\mathbf h_i,\mathbf h_j)\)。
    2. 汇总:节点 \(i\) 把来自所有邻居 \(\mathcal N(i)\) 的消息加起来(或取平均、取最大)。加法不在乎顺序,这一点后面很关键。
    3. 更新:用另一个共享的小网络 \(\psi\) 把汇总结果和自己原来的状态合成新的 \(\mathbf h_i\)。

    一层之后,节点只“听说”了它的直接邻居;两层之后,邻居已经带着邻居的邻居的消息,于是信息传了两跳。\(L\) 层 GNN 里,节点 \(i\) 的输出只依赖于 \(L\) 跳以内的节点:这就是它的感受野,和 CNN 每加一层感受野就变大(17.1 节)是同一回事。下图用最简单的、没有任何可学参数的消息传递来看这个过程:每个节点的新值是它自己和所有邻居的平均。我们只在一个“源”节点 s 放入 1,其余为 0,看这个信号怎样一层一层扩散。

    Every node \(i\) carries a feature vector \(\mathbf h_i\) (for a rope, a mass's velocity; for a robot, a joint angle; for an object, its class and position). One GNN layer does three things:

    1. Send messages: on every edge \(j\to i\) one shared small network \(\phi\) computes a message \(\mathbf m_{ij}=\phi(\mathbf h_i,\mathbf h_j)\).
    2. Aggregate: node \(i\) adds up the messages from all its neighbours \(\mathcal N(i)\) (or averages them, or takes the maximum). Addition does not care about order, which will matter a lot.
    3. Update: another shared small network \(\psi\) combines the aggregate with the node's old state into a new \(\mathbf h_i\).

    After one layer a node has "heard" only from its direct neighbours; after two, the neighbours already carry news from their own neighbours, so information has travelled two hops. In an \(L\)-layer GNN the output at node \(i\) depends only on nodes within \(L\) hops: that is its receptive field, the same thing as a CNN's receptive field growing with each layer (Lesson 17.1). The figure shows this with the simplest message passing there is, with no learnable parameters: each node's new value is the average of itself and all its neighbours. We put a 1 at one "source" node s and 0 everywhere else, and watch the signal spread layer by layer.

    FIG 1消息传递:L 层 = L 跳Message passing: L layers = L hops
    14 个节点、19 条边的图。点击节点可以设定源 s(琥珀色粗圈)或目标 t(紫色粗圈),由上方的选择器决定点击设定哪一个。每个节点里琥珀色圆盘的面积正比于它在第 \(L\) 层的值(相对于当前最大值);没有圆盘就是值为 0,信号还没到。琥珀色粗边是第 \(L\) 层真正传递了非零消息的边。紫色虚线圈标出目标 t 的感受野:距离 t 不超过 \(L\) 跳的节点。源落进这个区域,目标才会亮。 A graph with 14 nodes and 19 edges. Click a node to make it the source s (thick amber ring) or the target t (thick purple ring); the selector above decides which one a click sets. The area of the amber disc inside each node is proportional to its value at layer \(L\) (relative to the current maximum); no disc means the value is 0 and the signal has not arrived. Thick amber edges are the ones that carried a nonzero message in layer \(L\). Dashed purple circles mark the receptive field of the target t: the nodes at most \(L\) hops from it. The target lights up only once the source falls inside that region.
    试一试Try this
    • 选一对相距至少 4 跳的源和目标(默认那一对相距 5 跳),找出让目标刚好亮起来的最小层数 \(L\):它正好等于两者之间的跳数。Pick a source and a target at least 4 hops apart (the default pair is 5 apart) and find the smallest number of layers \(L\) at which the target lights up: it equals the hop distance between them.
    • 找一个源,使得只用 3 层就能让全部 14 个节点都亮起来。(只有一个节点做得到:图的“中心”。)Find a source from which only 3 layers light up all 14 nodes. (Exactly one node can do it: the "centre" of the graph.)
    核心洞见Key insight

    GNN 由局部规则定义:每个节点只和邻居交换消息,规则在所有节点、所有边上共享,就像 CNN 在所有像素上共享同一个卷积核。共享带来两样好处:参数个数和图的大小无关;图里某处学到的规律,在别处、甚至在更大的图上也能用。代价是:信息每层只能走一跳,远处的东西要很多层才能互相影响。

    A GNN is defined by local rules: each node only exchanges messages with its neighbours, and the rules are shared by every node and every edge, just as a CNN shares one kernel across every pixel. Sharing buys two things: the number of parameters does not depend on the size of the graph, and a regularity learned in one part of a graph applies elsewhere, even in larger graphs. The price: information moves one hop per layer, so distant things need many layers to influence each other.

    3动手:现场训练一个“学出来的模拟器”Play: train a learned simulator live

    给真实的绳子、布料或面团写一个准确的物理模型很难,参数也难测。另一条路是让网络从数据里学会“下一步会怎样”,再像模拟器一样一步步滚动预测,这类模型叫学出来的模拟器(learned simulator),学动力学模型的一般方法见 24.1 节。GNN 特别适合做这件事,因为物理本来就是局部的:一个质点的加速度只取决于和它相连的弹簧。

    下面的“真实世界”是一根质点-弹簧绳:每个质点质量为 1,弹簧刚度 \(K=400\)(单位质量下为 N/m),静止长度 \(L_0=0.4\) m,有重力和速度阻尼 \(1.5\,\mathrm{s^{-1}}\),第一个质点被钉住(可以拖动)。图的节点是质点,边是弹簧。GNN 只做一轮消息传递:

    • 每条边用两质点的相对位移 \(\mathbf d_{ij}=\mathbf x_j-\mathbf x_i\) 算出一条消息 \(\mathbf m_{ij}\)(可以理解为“弹簧对 \(i\) 的拉力”,但网络并不知道有弹簧这回事)。
    • 节点把所有消息加起来,再加上一个只看自己速度的项 \(\psi(\mathbf v_i)\)(让它学会重力和阻尼),得到加速度 \(\hat{\mathbf a}_i\)。
    • 用半隐式欧拉法积分(\(\Delta t=1/240\) s,2.5 节)得到下一时刻的状态,再把它喂回 GNN:这就是“滚动”(rollout)。

    训练数据是 600 个随机形状、随机速度的6 质点绳子快照,损失是预测加速度和真实加速度之间的均方误差(16.1 节的监督回归)。我们同时训练两种边网络,它们只在一点上不同:通用版 \(\mathbf m_{ij}=\mathrm{MLP}(d_x,d_y,\|\mathbf d\|)\in\R^2\);等变版先只用长度算一个标量,再沿弹簧方向放出去,\(\mathbf m_{ij}=\mathrm{MLP}(\|\mathbf d\|)\,\mathbf d/\|\mathbf d\|\)。两者都只用相对位置,所以整根绳子平移时预测不变;等变版还保证:整根绳子旋转,消息跟着一起旋转。

    Writing an accurate physical model of a real rope, cloth or lump of dough is hard, and its parameters are hard to measure. The alternative is to let a network learn "what happens next" from data and then roll it forward step by step like a simulator: a learned simulator (the general method of learning dynamics models is in Lesson 24.1). GNNs suit this especially well because physics is local: a mass's acceleration depends only on the springs attached to it.

    The "real world" below is a mass-spring rope: every mass is 1, the spring stiffness is \(K=400\) (N/m per unit mass), the rest length is \(L_0=0.4\) m, and there is gravity plus a velocity damping of \(1.5\,\mathrm{s^{-1}}\); the first mass is pinned (and you can drag it). The graph's nodes are the masses and its edges the springs. The GNN does just one round of message passing:

    • Each edge turns the relative displacement \(\mathbf d_{ij}=\mathbf x_j-\mathbf x_i\) of its two masses into a message \(\mathbf m_{ij}\) (think "the pull of the spring on \(i\)", although the network does not know there is a spring).
    • Each node adds up its messages and a term \(\psi(\mathbf v_i)\) that sees only its own velocity (so it can learn gravity and damping), giving the acceleration \(\hat{\mathbf a}_i\).
    • A semi-implicit Euler step (\(\Delta t=1/240\) s, Lesson 2.5) gives the next state, which is fed back into the GNN: the "rollout".

    The training data are 600 snapshots of 6-mass ropes with random shapes and velocities, and the loss is the mean squared error between predicted and true accelerations (the supervised regression of Lesson 16.1). We train two edge networks at once, which differ in one thing only: the generic one is \(\mathbf m_{ij}=\mathrm{MLP}(d_x,d_y,\|\mathbf d\|)\in\R^2\); the equivariant one computes a single number from the length and sends it out along the spring, \(\mathbf m_{ij}=\mathrm{MLP}(\|\mathbf d\|)\,\mathbf d/\|\mathbf d\|\). Both see only relative positions, so shifting the whole rope leaves the prediction unchanged; the equivariant one also guarantees that rotating the whole rope rotates the messages with it.

    FIG 2学出来的模拟器:在 6 质点绳子上训练,在别的图上滚动A learned simulator: train on 6-mass ropes, roll out on other graphs
    左:紫色空心圈和粗线是真实物理,琥珀色是通用 GNN 的滚动预测,蓝色方块是等变 GNN 的滚动预测;三者从同一个初始状态出发,钉点由你拖动的圆形手柄决定(布料有两个钉点,一起移动)。真实绳子里拉伸超过 1.6 \(L_0\)(训练数据里最长的弹簧)的那一段会变成红色。训练在后台进行,滚动用的始终是当前的权重。右:两个模型在 100 个未见过的 6 质点快照上的相对加速度误差(对数坐标),虚线是 5%。“偏差”是同一时刻预测质点与真实质点的平均距离;“静止”指真实绳子和等变绳子的动能都低于 \(10^{-3}\)。如果某个模型的绳子数值发散,它会被重置到真实状态,并记一次“重置”。 Left: purple hollow circles and the thick line are the true physics, amber is the rollout of the generic GNN, blue squares the rollout of the equivariant GNN; all three start from the same state, and the pin follows the round handle you drag (the cloth has two pins that move together). Any segment of the true rope stretched beyond 1.6 \(L_0\) (the longest spring in the training data) turns red. Training runs in the background and the rollouts always use the current weights. Right: both models' relative acceleration error on 100 unseen 6-mass snapshots (log scale); the dashed line is 5%. "Gap" is the mean distance between predicted and true masses at the same moment; "at rest" means the kinetic energies of the true and the equivariant ropes are both below \(10^{-3}\). If a model's rope blows up numerically it is reset to the true state and a "reset" is counted.
    • 按“训练”:等变模型大约 100 步就把测试误差压到 3% 以下;通用模型要大约 1700 步才降到 5% 以下(视电脑快慢,几秒到半分钟)。等到通用模型也低于 5%。Press "Train": the equivariant model gets its test error below 3% in about 100 steps; the generic model needs about 1700 steps to get below 5% (a few seconds to half a minute, depending on your computer). Wait until the generic model is below 5% too.
    • 两个模型都训练好以后(通用模型低于 5%),保持 6 质点绳子,按“释放”,等它停下来:等变绳子停在离真实绳子 1 cm 以内的地方,通用绳子通常差好几厘米甚至更多。With both models trained (generic below 5%), keep the 6-mass rope, press "Release" and wait until it is still: the equivariant rope comes to rest within 1 cm of the true one, while the generic rope is usually several centimetres off or more.
    • 切换到“布料 3×4”(12 个质点,每个有 2 到 4 个邻居,两个钉点:训练里从没见过这样的图)。在等变模型误差低于 3% 时释放并等它静止:等变布料的偏差仍在 1 cm 以内。Switch to "cloth 3×4" (12 masses with 2 to 4 neighbours each and two pins: a graph never seen in training). With the equivariant model below 3%, release it and wait until it is still: the equivariant cloth is still within 1 cm.
    值得注意的几件事Things worth noticing

    (1) 同一个网络,换一张图照样能用:模型只在 6 质点的绳子上训练过,却能直接模拟 12 质点的绳子和一块布,因为它学的是“一根弹簧怎样拉一个质点”这条局部规律,而布料只是把同样的局部片段换了一种拼法。MLP 做不到这一点:它的输入长度就是 6 个质点。 (2) 对的对称性比更多的数据管用:等变模型只需要学一个一维函数(拉力随长度怎样变),通用模型却要在每个方向上分别学会“拉力沿着弹簧”。两者的单步误差都只有几个百分点时,静止形状的差别仍然很大:挂着的绳子对横向的力很敏感,单步预测里方向上一点点的偏差,就会让它歪出几厘米。 (3) 局部规律只在训练见过的范围里可靠:切到 12 质点绳子,让它静止下来,最上面的弹簧被下面 11 个质点拉长到约 1.67 \(L_0\),超过了训练数据里最长的 1.6 \(L_0\)(红色那一段)。这里等变模型的偏差明显更大:训练早期有几厘米(100 步时约 6 cm),要再训练几千步才缩到 1 cm 左右。

    (1) One network, another graph: the model was trained only on 6-mass ropes, yet it simulates a 12-mass rope and a cloth directly, because what it learned is the local law "how one spring pulls one mass", and the cloth just assembles the same local pieces differently. An MLP cannot do this: its input length is six masses. (2) The right symmetry beats more data: the equivariant model only has to learn a one-dimensional function (how the pull depends on length), while the generic model must learn "the pull points along the spring" separately for every direction. Even when both have single-step errors of a few percent, their resting shapes differ a lot: a hanging rope is very sensitive to sideways forces, so a slight error in the direction of each predicted force bends it by several centimetres. (3) A local law is only trustworthy where training has been: switch to the 12-mass rope and let it settle. Its top spring is stretched by the 11 masses below to about 1.67 \(L_0\), beyond the longest spring in the training data, 1.6 \(L_0\) (the red segment). There the equivariant model's gap is clearly larger: several centimetres early in training (about 6 cm at 100 steps), and it takes thousands more steps to shrink to around 1 cm.

    4另外几个视角:编号、注意力、Transformer 与层数More views: numbering, attention, transformers and depth

    置换等变:一个策略,控制许多种身体Permutation equivariance: one policy for many bodies

    给图的节点重新编号,图本身并没有变。GNN 的每一步都只用“我的邻居是谁”和“加起来”,不用“我是第几号”,所以重新编号之后,每个节点的输出原封不动地跟着它走:这叫置换等变(permutation equivariance)。如果再把所有节点的输出加起来得到整张图的一个向量(readout),这个向量连跟着走都不用,完全不变:置换不变。

    这对机器人的意义是:同一个 GNN 策略可以读入任意一种身体的“关节图”,为每个关节输出一个力矩。下图里的策略是一个随机初始化的两层消息传递网络(没有训练,我们只关心它的结构性质):节点特征是关节类型(躯干、髋、膝、踝或蛇的体节,独热编码)加上关节角和角速度,关节角随时间按步态变化。作为对比,旁边是一个把所有关节特征按编号顺序拼起来的 MLP 策略。

    Renumbering the nodes of a graph does not change the graph. Every step of a GNN uses only "who my neighbours are" and "add them up", never "what number I am", so after renumbering each node's output stays exactly the same and simply travels with the node: this is permutation equivariance. If we also add up the outputs of all nodes to get one vector for the whole graph (a readout), that vector does not even move: it is permutation invariant.

    For robots this means one GNN policy can read the "joint graph" of any body and output a torque for every joint. The policy below is a randomly initialized two-layer message-passing network (untrained: we only care about its structural properties). Node features are the joint type (torso, hip, knee, ankle or snake segment, one-hot) plus the joint angle and angular velocity, and the angles change over time with a gait. For comparison, next to it is an MLP policy that concatenates all joint features in index order.

    FIG 3重新编号:GNN 的输出跟着关节走,MLP 的不会Renumbering: the GNN's outputs follow the joints, the MLP's do not
    每个圆是一个关节(节点),里面的数字是它当前的编号,灰色粗线是连杆(边)。每个关节旁有两根条:上面蓝色是 GNN 策略给这个关节的力矩,下面红色是 MLP 策略给的(向右为正)。按“打乱编号”会暂停步态,并用空心框留下打乱前的力矩,方便比较:蓝条落回自己的框里,红条却跳到别处。右侧读数给出打乱前后同一个物理关节的力矩最大变化,以及两种策略的参数个数。 Each circle is a joint (a node) with its current index inside; the thick grey lines are the links (edges). Next to each joint are two bars: the upper blue one is the GNN policy's torque for that joint, the lower red one the MLP policy's (rightwards is positive). "Shuffle indices" pauses the gait and leaves hollow boxes at the torques from before the shuffle, for comparison: the blue bars land back in their boxes, the red ones jump elsewhere. The readout on the right gives the largest change of torque at the same physical joint before and after, and the parameter counts of both policies.
    • 在至少 3 种身体上各按一次“打乱编号”:GNN 的力矩变化每次都是 0(最多是 \(10^{-16}\) 量级的浮点舍入),MLP 的变化则是 1 的量级;GNN 的参数个数始终是 893,MLP 的参数个数随关节数变化,换一种身体就得重新训练。On at least 3 different bodies press "Shuffle indices" once each: the GNN's torque change is 0 every time (at most floating-point rounding of order \(10^{-16}\)), while the MLP's change is of order 1; the GNN always has 893 parameters, while the MLP's count changes with the number of joints and a new body means retraining.

    等变性也有另一面:GNN 分不清两个“看起来一样”的节点。如果四条腿的特征完全相同,它们必然得到完全相同的力矩,网络不可能让左前腿和右后腿做不同的事。所以真实的形态学策略会给节点加上能区分它们的特征,比如关节类型、关节在身体上的位置、或者它在树里的深度(这里用的是类型,加上各关节在步态里不同的相位)。

    Equivariance has another side: a GNN cannot tell apart two nodes that "look the same". If all four legs had identical features they would necessarily get identical torques; the network could not make the left front leg do something different from the right hind leg. Real morphology policies therefore give nodes features that distinguish them, such as the joint type, the joint's position on the body or its depth in the tree (here: the type, plus the different phase each joint has in the gait).

    GCN 与 GAT:固定权重还是学出来的权重GCN and GAT: fixed weights or learned weights

    汇总邻居时,每个邻居该占多大比重?图卷积网络(GCN,Kipf 与 Welling,2017)的答案由图的结构决定:每个邻居(连同自己)按度数归一化后的固定权重,平均下来大致是 \(1/(d_i+1)\),\(d_i\) 是节点的度数。图注意力网络(GAT,Veličković 等,2018)则让网络自己决定:对每条边算一个分数,在邻居之间做 softmax,得到权重 \(\alpha_{ij}\),这和 17.3 节的注意力是同一个机制,只是每个节点只能注意它的邻居。

    什么时候这个区别要紧?看一个编队任务:一群机器人里,每台跟随者都要输出领队广播的速度指令 \(s\)。它的邻居里恰好有一台领队,其余是其他跟随者,各自也报着自己的 \(s\)(干扰项)。节点特征是 \([b_j,\ s_j]\),领队的 \(b_j=1\),其余为 0。下面同时训练一个单层 GCN 和一个单层 GAT,两者的消息变换和输出层完全一样,唯一的区别是权重来源:GCN 用均匀权重,GAT 用学出来的注意力。每一步用 16 个新的随机样本,邻居数在 2 到 6 之间。

    When aggregating neighbours, how much should each one count? The graph convolutional network (GCN, Kipf & Welling, 2017) lets the graph's structure decide: each neighbour (and the node itself) gets a fixed weight from degree normalization, roughly \(1/(d_i+1)\) on average, where \(d_i\) is the node's degree. The graph attention network (GAT, Veličković et al., 2018) lets the network decide: it scores every edge, takes a softmax over the neighbours, and uses the result \(\alpha_{ij}\) as weights. This is the attention mechanism of Lesson 17.3, except that each node may attend only to its neighbours.

    When does the difference matter? Take a formation task: in a group of robots every follower must output the speed command \(s\) broadcast by its leader. Exactly one of its neighbours is a leader; the others are followers, each reporting its own \(s\) (distractors). Node features are \([b_j,\ s_j]\), with \(b_j=1\) for the leader and 0 otherwise. Below, a single-layer GCN and a single-layer GAT train side by side. Their message transform and output layer are identical; the only difference is where the weights come from: uniform for the GCN, learned attention for the GAT. Every step uses 16 fresh random samples with 2 to 6 neighbours.

    FIG 4跟随领队:均匀平均做不到,注意力做得到Follow the leader: a uniform average cannot, attention can
    左:同一个样本分别交给 GCN(蓝色)和 GAT(琥珀色)。中心是要做决定的跟随者,周围是它的邻居,每个节点旁写着它报出的 \(s\);领队带紫色粗圈和字母 L。边的粗细和旁边的数字是这条边的权重(GCN 是均匀的 \(1/(k+1)\),GAT 是 \(\alpha_{ij}\)),中心节点给自己的权重写在它正下方;每个面板最下方是预测 \(\hat y\) 和目标 \(y\),误差小于 0.05 时显示为绿色,否则为红色。右:300 个固定测试样本上的均方误差(对数坐标)。 Left: the same sample handed to the GCN (blue) and to the GAT (amber). In the middle is the follower that must decide, around it are its neighbours, and each node shows the \(s\) it reports; the leader has a thick purple ring and the letter L. The thickness of each edge and the number on it are its weight (uniform \(1/(k+1)\) for the GCN, \(\alpha_{ij}\) for the GAT); the centre node's weight on itself is written just below it, and at the bottom of each panel are the prediction \(\hat y\) and the target \(y\), in green when they differ by less than 0.05 and in red otherwise. Right: the mean squared error on 300 fixed test samples (log scale).
    • 按“训练”:几百步内 GAT 的测试误差降到 \(10^{-3}\) 以下,而 GCN 一直停在 0.28 左右(目标 \(s\) 本身的方差是 1/3,GCN 只解释了其中一小部分)。Press "Train": within a few hundred steps the GAT's test error drops below \(10^{-3}\), while the GCN stays around 0.28 (the variance of the target \(s\) itself is 1/3, so the GCN explains only a small part of it).
    • 训练好之后按几次“换一个样本”,找一个至少有 5 个邻居的样本:GAT 给领队的权重仍然超过 0.9,其余边几乎为零。Once trained, press "New sample" a few times to find a sample with at least 5 neighbours: the GAT still gives the leader a weight above 0.9 and the other edges almost nothing.

    为什么 GCN 学不会?它的输出是邻居特征的固定加权平均再做变换,领队的 \(s\) 只占其中 \(1/(k+1)\),而且混着其他跟随者的 \(s\):网络无法根据“是否领队”这个特征去调整权重,因为权重根本不由特征决定。GAT 的分数函数看得到这个特征,只要给“是领队”很大的分数,softmax 就把几乎全部权重给它。这不是说 GCN 没用:当邻居都同样重要(比如平滑一个传感器场,或者网格上的扩散)时,固定权重正合适,而且更便宜、更稳定。

    Why can the GCN not learn this? Its output is a fixed weighted average of the neighbours' features followed by a transform, in which the leader's \(s\) is only a \(1/(k+1)\) share, mixed with the followers' values: the network cannot use the "is leader" feature to change the weights, because the weights do not depend on features at all. The GAT's score function does see that feature: by giving "is leader" a large score, the softmax hands nearly all the weight to it. This does not make GCNs useless: when all neighbours matter equally (smoothing a sensor field, diffusion on a mesh), fixed weights are exactly right, and cheaper and more stable.

    Transformer 是完全图上的 GNNA transformer is a GNN on the complete graph

    把 GAT 的“只注意邻居”去掉,让每个节点注意所有节点,就得到了 17.3 节的自注意力层:Transformer 就是在完全图上做消息传递的 GNN,注意力权重就是边上的权重。反过来,一个 GNN 也可以看成一个带“掩码”的 Transformer:不相连的节点对的注意力分数被设成 \(-\infty\),softmax 之后权重为 0。区别就在于这张图从哪里来:GNN 把“谁和谁有关”作为先验写死在图里,Transformer 让网络自己去学。

    下图有 10 个 token(可以想成场景里的 10 个物体,位置可拖动),图由半径 \(r\) 决定:距离不超过 \(r\) 的两个 token 之间有边。右边是 \(10\times10\) 的注意力矩阵,每一行是一个 token 对其他 token 的权重。两种分数:局部分数 \(e_{ij}=-\|\mathbf p_i-\mathbf p_j\|^2/2\),近的物体互相关注,类似物理相互作用;非局部分数 \(e_{ij}=1.2\,x_j\),所有人都去看最东边的那个物体(像所有机器人都盯着同一个目标)。

    Drop GAT's "attend only to neighbours", let every node attend to every node, and you have the self-attention layer of Lesson 17.3: a transformer is a GNN doing message passing on the complete graph, with the attention weights as edge weights. Conversely, a GNN can be seen as a transformer with a "mask": the scores of unconnected pairs are set to \(-\infty\), so after the softmax their weight is 0. The whole difference is where the graph comes from: a GNN hard-codes "who is related to whom" as a prior in the graph, a transformer lets the network learn it.

    The figure has 10 tokens (think of 10 objects in a scene; drag them), and the graph is set by a radius \(r\): two tokens at most \(r\) apart are joined by an edge. On the right is the \(10\times10\) attention matrix; each row holds one token's weights over the others. There are two kinds of scores: local scores \(e_{ij}=-\|\mathbf p_i-\mathbf p_j\|^2/2\), where nearby objects attend to each other, much like physical interactions; and non-local scores \(e_{ij}=1.2\,x_j\), where everyone looks at the easternmost object (as when every robot watches the same target).

    FIG 5注意力加掩码 = GNN;去掉掩码 = TransformerMasked attention = GNN; no mask = transformer
    左:token 与半径图,悬停或拖动一个 token,它那一行在右边的矩阵里会被框出来,它的半径用青色虚线圆画出。右:注意力矩阵,行是“谁在看”,列是“被看的”。每个格子里琥珀色方块的面积正比于掩码之后的权重;被掩码去掉的格子只画一个小点(悬停公式里的 \(M_{ij}\) 时变成红色叉)。“丢失的注意力”是:如果不加掩码(完全图),这一行本该分给图外 token 的那部分权重。 Left: the tokens and the radius graph; hover or drag a token to outline its row in the matrix on the right and draw its radius as a dashed cyan circle. Right: the attention matrix, rows are "who looks", columns "who is looked at". The area of the amber square in each cell is proportional to the weight after masking; masked-out cells show only a small dot (a red cross while you hover \(M_{ij}\) in the formulas). "Lost attention" is the share of a row's weight that, without a mask (the complete graph), would have gone to tokens outside the graph.
    • 用“局部”分数,调半径使得算的格子少于一半(少于 50 个),同时每一行丢失的注意力都不到 5%:掩码几乎不损失什么,却省了一半以上的计算。With "local" scores, set the radius so that fewer than half of the cells (fewer than 50) are computed while every row loses less than 5% of its attention: the mask costs almost nothing and saves more than half the work.
    • 保持同样少的格子(少于 50 个),换成“非局部”分数:平均每行丢失的注意力超过 30%。局部的图在这里成了错误的先验。Keep the cell count just as low (fewer than 50) and switch to "non-local" scores: the average row now loses more than 30% of its attention. The local graph has become the wrong prior.

    这就是选 GNN 还是 Transformer 的核心权衡。如果相互作用真的是局部的(弹簧、接触、相邻的点),图是一个好先验:计算量随边数线性增长而不是 \(n^2\),数据也省。如果重要的关系可能出现在任意两个东西之间(一句话里相距很远的两个词,一个机器人策略里“看到的物体”和“要动的关节”),完全图更安全,代价是 \(O(n^2)\) 的计算。完全图里没有结构信息,所以 Transformer 必须靠位置编码知道 token 之间的关系;图 Transformer 常用图拉普拉斯矩阵的特征向量或随机游走统计量作为节点的位置编码,把图的结构以“软”的方式交还给它。

    This is the core trade-off between a GNN and a transformer. If the interactions really are local (springs, contacts, neighbouring points), the graph is a good prior: the cost grows with the number of edges instead of \(n^2\), and less data is needed. If an important relation can appear between any two things (two words far apart in a sentence; in a robot policy, a seen object and the joint that must move), the complete graph is safer, at a cost of \(O(n^2)\). The complete graph carries no structure, so a transformer needs positional encodings to know how tokens relate; graph transformers often use eigenvectors of the graph Laplacian or random-walk statistics as node positional encodings, giving the structure back in a "soft" form.

    层数太多:过平滑Too many layers: oversmoothing

    既然 \(L\) 层只能看到 \(L\) 跳,那把层数加到很多不就行了?问题是:每一层都在对邻居做平均,而反复平均会把所有节点的特征拉到同一个值,就像热量在一块金属里扩散到处处同温。这叫过平滑(oversmoothing)。下图是两个社区(各 10 个节点,圆形和方形)组成的图,社区内部连得紧,之间只有 7 条桥(紫色虚线)。初始特征是“社区 A 为 +1,B 为 −1”再加噪声,然后反复做 FIG 1 那样的均值聚合。

    If \(L\) layers see only \(L\) hops, why not just use many layers? The problem: every layer averages over neighbours, and repeated averaging pulls the features of all nodes towards one value, like heat spreading through a piece of metal until it is the same temperature everywhere. This is oversmoothing. The graph below has two communities (10 nodes each, circles and squares), tightly connected inside and joined by only 7 bridges (dashed purple). The initial features are "+1 for community A, −1 for B" plus noise, and then the mean aggregation of FIG 1 is applied over and over.

    FIG 6过平滑:先去噪,再把一切抹平Oversmoothing: first denoising, then everything is washed out
    左:社区 A 是圆形节点,B 是方形节点。节点里圆盘的面积正比于特征的绝对值(相对于初始特征的最大绝对值),琥珀色为正、青色为负。右:随层数 \(L\) 变化的两个量(对数坐标):紫色是两个社区平均值之差(“社区差”,这是我们想保留的信号),绿色是社区内部的标准差(“社区内离散”,主要是噪声);虚线是 \(\lambda_2^L\) 乘以初始的社区差,竖线是当前的 \(L\)。滑块 \(\alpha\) 加入“初始残差”:每一层把一部分原始特征重新混进来(APPNP 的做法)。 Left: community A are the round nodes, B the square ones. The area of the disc inside each node is proportional to the feature's absolute value (relative to the largest absolute initial feature), amber for positive, cyan for negative. Right: two quantities against the number of layers \(L\) (log scale): purple is the difference between the two communities' means (the "community gap", the signal we want to keep), green is the standard deviation inside the communities (the "within spread", mostly noise); the dashed line is \(\lambda_2^L\) times the initial gap, and the vertical line marks the current \(L\). The slider \(\alpha\) adds an "initial residual": every layer mixes a share of the original features back in (as APPNP does).
    • \(\alpha=0\) 时把层数拉到让社区差跌破初始值的 1%(需要 54 层以上):圆盘几乎消失,两个社区再也分不开。注意前 2 层:社区内离散从 0.61 降到 0.28,而社区差只从 1.96 降到 1.50,几层平均其实是在去噪。With \(\alpha=0\) increase the layers until the community gap falls below 1% of its initial value (it takes 54 layers or more): the discs nearly vanish and the communities can no longer be told apart. Notice the first 2 layers: the within spread drops from 0.61 to 0.28 while the gap only goes from 1.96 to 1.50, so a few rounds of averaging actually denoise.
    • 把 \(\alpha\) 设到 0.1 或以上,再把层数拉到 64:社区差停在初始值的一半左右,不再随层数衰减。Set \(\alpha\) to 0.1 or more and push the layers to 64: the community gap settles at about half its initial value and stops decaying with depth.
    一个想法,几种看法One idea, several views

    卷积:CNN 是规则网格图上的 GNN,但它更强一点:卷积核对“左边的邻居”和“右边的邻居”用不同的权重,而普通 GNN 只能对所有邻居用同一个函数,除非边特征里带着方向(FIG 2 的相对位移就是这样的边特征)。 集合:没有边的 GNN(每个节点只和自己说话,最后求和)就是 Deep Sets,PointNet 用最大值池化做点云分类也是这种置换不变的结构。 注意力:GAT 是带掩码的注意力,Transformer 是完全图上的 GAT(FIG 5)。 概率推断:因子图上的置信传播也是“沿着边传消息、在节点上汇总”,GNN 可以看成把手写的消息规则换成了学出来的网络。 扩散:一层均值聚合是图上的一步热扩散,过平滑就是扩散到了稳态(FIG 6)。

    Convolution: a CNN is a GNN on a regular grid graph, but a slightly stronger one: its kernel uses different weights for "the neighbour on the left" and "the neighbour on the right", whereas a plain GNN applies one function to all neighbours unless the edge features carry direction (the relative displacement in FIG 2 is such an edge feature). Sets: a GNN with no edges (each node talks only to itself, then everything is summed) is Deep Sets, and PointNet's max-pooled point-cloud classifier has the same permutation-invariant structure. Attention: GAT is masked attention, and a transformer is a GAT on the complete graph (FIG 5). Probabilistic inference: belief propagation on a factor graph also "passes messages along edges and aggregates at nodes"; a GNN can be read as replacing the hand-derived message rules with learned networks. Diffusion: one layer of mean aggregation is one step of heat diffusion on the graph, and oversmoothing is diffusion reaching steady state (FIG 6).

    5再看数学The math

    提示:把鼠标悬停在公式中带底色的符号上,图中对应的元素会被高亮(邻居、感受野、消息、编号、注意力权重、掩码、\(\lambda_2\) 曲线)。Tip: hover the highlighted symbols in the formulas; matching elements in the figures light up (neighbours, receptive field, messages, indices, attention weights, the mask, the \(\lambda_2\) curve).

    图与消息传递Graphs and message passing

    图 \(G=(\mathcal V,\mathcal E)\) 有 \(n\) 个节点,邻接矩阵 \(A\in\{0,1\}^{n\times n}\)(\(A_{ij}=1\) 表示 \(i,j\) 相连),节点特征按行堆成 \(X\in\R^{n\times d}\),边可以有特征 \(\mathbf e_{ij}\)(比如相对位移)。记 \(\mathbf h_i^{(0)}=\mathbf x_i\)。一般的消息传递神经网络(MPNN,Gilmer 等,2017)的第 \(l\) 层是

    A graph \(G=(\mathcal V,\mathcal E)\) has \(n\) nodes and an adjacency matrix \(A\in\{0,1\}^{n\times n}\) (\(A_{ij}=1\) when \(i\) and \(j\) are connected); node features are stacked as rows of \(X\in\R^{n\times d}\), and edges may carry features \(\mathbf e_{ij}\) (a relative displacement, say). Let \(\mathbf h_i^{(0)}=\mathbf x_i\). Layer \(l\) of a general message-passing neural network (MPNN, Gilmer et al., 2017) is

    $$ \mathbf m_{ij}^{(l)}=\phi^{(l)}\big(\mathbf h_i^{(l)},\mathbf h_j^{(l)},\mathbf e_{ij}\big),\qquad \mathbf h_i^{(l+1)}=\psi^{(l)}\Big(\mathbf h_i^{(l)},\ \bigoplus_{j\in\hl{nbr}{\mathcal N(i)}}\mathbf m_{ij}^{(l)}\Big) $$

    \(\phi\) 和 \(\psi\) 是小 MLP,在所有边、所有节点上共享;\(\bigoplus\) 是对邻居的求和、平均或最大值,任何“与顺序无关”的运算都行。反复代入可知 \(\mathbf h_i^{(L)}\) 只依赖于 \(\hl{rf}{\mathcal N_L(i)}=\{j:\operatorname{dist}(i,j)\le L\}\) 里的输入:这就是 FIG 1 的感受野。FIG 1 的无参数版本是 \(\phi(\mathbf h_i,\mathbf h_j)=\mathbf h_j\)、\(\bigoplus\) 取和、\(\psi\) 除以 \(\deg(i)+1\),整层写成矩阵就是 \(H^{(l+1)}=\tilde D^{-1}\tilde AH^{(l)}\),其中 \(\tilde A=A+I\) 加了自环,\(\tilde D\) 是 \(\tilde A\) 的度数对角阵。

    FIG 2 的学出来的模拟器是 \(L=1\) 的特例(Battaglia 等的 interaction network 正是这种“边算作用、节点汇总”的结构):

    \(\phi\) and \(\psi\) are small MLPs shared by every edge and every node; \(\bigoplus\) is a sum, mean or maximum over neighbours, any operation that ignores order. Substituting repeatedly shows that \(\mathbf h_i^{(L)}\) depends only on inputs in \(\hl{rf}{\mathcal N_L(i)}=\{j:\operatorname{dist}(i,j)\le L\}\): the receptive field of FIG 1. FIG 1's parameter-free version is \(\phi(\mathbf h_i,\mathbf h_j)=\mathbf h_j\) with a sum for \(\bigoplus\) and \(\psi\) dividing by \(\deg(i)+1\); as a matrix the whole layer is \(H^{(l+1)}=\tilde D^{-1}\tilde AH^{(l)}\), where \(\tilde A=A+I\) adds self-loops and \(\tilde D\) is the diagonal degree matrix of \(\tilde A\).

    The learned simulator of FIG 2 is the special case \(L=1\) (the interaction network of Battaglia et al. has exactly this "edges compute effects, nodes aggregate" structure):

    $$ \hat{\mathbf a}_i=\hl{msg}{\sum_{j\in\mathcal N(i)}\phi(\mathbf x_j-\mathbf x_i)}+\psi(\mathbf v_i),\qquad \mathcal L(\theta)=\frac{1}{|\mathcal D|}\sum_{(X,V)\in\mathcal D}\ \frac{1}{|\mathcal F|}\sum_{i\in\mathcal F}\big\|\hat{\mathbf a}_i-\mathbf a_i\big\|^2 $$ $$ \phi_1(\mathbf d)=\mathrm{MLP}(d_x,d_y,\|\mathbf d\|),\qquad \phi_2(\mathbf d)=\mathrm{MLP}(\|\mathbf d\|)\,\frac{\mathbf d}{\|\mathbf d\|}\ \ \Rightarrow\ \ \phi_2(R\mathbf d)=R\,\phi_2(\mathbf d)\ \ \forall R\in\mathrm{SO}(2) $$

    真实加速度是 \(\mathbf a_i=\sum_j K(\|\mathbf d_{ij}\|-L_0)\,\mathbf d_{ij}/\|\mathbf d_{ij}\|+\mathbf g-c\,\mathbf v_i\),其中 \(\mathcal D\) 是训练快照的集合,\(\mathcal F\) 是没被钉住的质点;\(\phi_1\) 是通用版,\(\phi_2\) 是等变版。等变版只需要学会一维函数 \(K(\|\mathbf d\|-L_0)\)。滚动时 \(\mathbf v\leftarrow\mathbf v+\Delta t\,\hat{\mathbf a}\),\(\mathbf x\leftarrow\mathbf x+\Delta t\,\mathbf v\)。悬停 \(\sum_j\phi\) 会在 FIG 2 里画出等变模型在每个质点上的消息之和(绿色箭头)。

    The true acceleration is \(\mathbf a_i=\sum_j K(\|\mathbf d_{ij}\|-L_0)\,\mathbf d_{ij}/\|\mathbf d_{ij}\|+\mathbf g-c\,\mathbf v_i\), where \(\mathcal D\) is the set of training snapshots and \(\mathcal F\) the masses that are not pinned; \(\phi_1\) is the generic model and \(\phi_2\) the equivariant one. The equivariant model only has to learn the one-dimensional function \(K(\|\mathbf d\|-L_0)\). The rollout is \(\mathbf v\leftarrow\mathbf v+\Delta t\,\hat{\mathbf a}\), \(\mathbf x\leftarrow\mathbf x+\Delta t\,\mathbf v\). Hovering \(\sum_j\phi\) draws the equivariant model's summed messages at every mass in FIG 2 (green arrows).

    置换等变与不变Permutation equivariance and invariance

    重新编号用置换矩阵 \(P\) 表示:特征变成 \(PX\),邻接矩阵变成 \(PAP^\top\)。设 \(F\) 是一层(或多层)GNN,输出每个节点一行。则

    A renumbering is a permutation matrix \(P\): the features become \(PX\) and the adjacency becomes \(PAP^\top\). Let \(F\) be one (or several) GNN layers, with one output row per node. Then

    $$ F\big(\hl{perm}{P}X,\ PAP^\top\big)=P\,F(X,A),\qquad r(X,A)=\sum_{i}F(X,A)_i\ \Rightarrow\ r\big(PX,PAP^\top\big)=r(X,A) $$

    左式是等变:输出跟着节点一起重排;右式是不变:读出完全不动。证明只要一行:节点 \(i\) 的新状态由它自己的特征和多重集 \(\{\mathbf h_j:j\in\mathcal N(i)\}\) 决定,重新编号不改变这个多重集,而 \(\bigoplus\) 不在乎元素的顺序。MLP 策略 \(f(\operatorname{vec}(X))\) 没有这个性质:它的第一层把第 1 个关节的特征乘上第 1 组权重,重新编号就换了一组权重,FIG 3 里的红条就是这样跳走的。

    The left identity is equivariance: the outputs are reordered along with the nodes; the right one is invariance: the readout does not move at all. The proof is one line: node \(i\)'s new state is decided by its own feature and the multiset \(\{\mathbf h_j:j\in\mathcal N(i)\}\); renumbering does not change that multiset, and \(\bigoplus\) ignores the order of its elements. An MLP policy \(f(\operatorname{vec}(X))\) lacks this property: its first layer multiplies joint 1's features by weight block 1, so a renumbering swaps in different weights, which is how the red bars in FIG 3 jump away.

    GCN、GAT 与 TransformerGCN, GAT and the transformer

    $$ H^{(l+1)}=\sigma\big(\tilde D^{-1/2}\tilde A\,\tilde D^{-1/2}H^{(l)}W^{(l)}\big) $$ $$ \hl{alpha}{\alpha_{ij}}=\frac{\exp\big(\mathrm{LeakyReLU}(\mathbf a^\top[W\mathbf h_i\,\|\,W\mathbf h_j])\big)}{\sum_{k\in\mathcal N(i)\cup\{i\}}\exp\big(\mathrm{LeakyReLU}(\mathbf a^\top[W\mathbf h_i\,\|\,W\mathbf h_k])\big)},\qquad \mathbf h_i'=\sigma\Big(\sum_{j\in\mathcal N(i)\cup\{i\}}\alpha_{ij}W\mathbf h_j\Big) $$ $$ \alpha_{ij}=\operatorname{softmax}_j\Big(\frac{\mathbf q_i^\top\mathbf k_j}{\sqrt{d}}+\hl{mask}{M_{ij}}\Big),\qquad M_{ij}=\begin{cases}0, & j\in\mathcal N(i)\cup\{i\}\\ -\infty, & j\notin\mathcal N(i)\cup\{i\}\end{cases} $$

    三行依次是 GCN、GAT 和带掩码的注意力。GCN 的权重 \(1/\sqrt{\tilde d_i\tilde d_j}\) 只由度数决定;GAT 的权重 \(\alpha_{ij}\) 由特征算出,\([\cdot\|\cdot]\) 是拼接,\(\mathbf a\) 是可学的打分向量,实际中还会像 Transformer 一样用多个“头”并行再拼接。最后一行把 17.3 节的注意力写成了 GNN:\(M\equiv0\) 时就是完全图,也就是普通的 Transformer 层;\(M\) 按图取 0 或 \(-\infty\) 时就是在图上做注意力。悬停 \(\alpha_{ij}\) 会在 FIG 4 里高亮 GAT 的权重标签,悬停 \(M_{ij}\) 会在 FIG 5 里把被掩码的格子标红。FIG 4 的 GAT 打分正是上式(多一个偏置项),只是 LeakyReLU 负半轴的斜率取 0.01,而不是原论文的 0.2;FIG 4 的 GCN 用的是均值形式的均匀权重 \(1/(k+1)\),而不是对称归一化。每层的计算量:GCN 和 GAT 都是 \(O(|\mathcal E|)\),完全图上的注意力是 \(O(n^2)\)。

    The three lines are the GCN, the GAT and masked attention. The GCN weights \(1/\sqrt{\tilde d_i\tilde d_j}\) depend only on degrees; the GAT weights \(\alpha_{ij}\) are computed from features, where \([\cdot\|\cdot]\) is concatenation and \(\mathbf a\) a learnable scoring vector; in practice several "heads" run in parallel and are concatenated, as in a transformer. The last line writes the attention of Lesson 17.3 as a GNN: with \(M\equiv0\) it is the complete graph, i.e. an ordinary transformer layer; with \(M\) set to 0 or \(-\infty\) by a graph it is attention on that graph. Hovering \(\alpha_{ij}\) highlights the GAT weight labels in FIG 4; hovering \(M_{ij}\) marks the masked cells of FIG 5 in red. FIG 4's GAT scores are exactly the formula above (plus a bias), except that the LeakyReLU's negative slope is 0.01 instead of the original paper's 0.2; FIG 4's GCN uses the uniform mean weights \(1/(k+1)\) rather than the symmetric normalization. The cost per layer is \(O(|\mathcal E|)\) for both GCN and GAT, and \(O(n^2)\) for attention on the complete graph.

    表达能力:求和、平均、最大值不一样Expressive power: sum, mean and max differ

    聚合函数决定 GNN 能区分哪些邻域。设一个节点的邻居特征多重集是 \(\{a\}\),另一个是 \(\{a,a\}\):平均和最大值给出一样的结果,求和却不同(\(a\) 对 \(2a\));多重集 \(\{a,b\}\) 与 \(\{a,a,b,b\}\) 平均值相同,\(\{a,b\}\) 与 \(\{a,b,b\}\) 最大值相同。Xu 等(2019)证明,只靠消息传递的 GNN 区分不同图的能力最多和 Weisfeiler-Lehman(1-WL)图同构测试一样强,而用“求和 + MLP”的 GIN 能达到这个上限。所以当“有几个”很重要时(几个接触点、几个邻居),用求和;FIG 2 正是这样:弹簧力是加起来的,平均就错了。

    The aggregator decides which neighbourhoods a GNN can tell apart. Let one node's multiset of neighbour features be \(\{a\}\) and another's \(\{a,a\}\): mean and max give the same result, the sum does not (\(a\) versus \(2a\)); the multisets \(\{a,b\}\) and \(\{a,a,b,b\}\) have the same mean, and \(\{a,b\}\) and \(\{a,b,b\}\) the same max. Xu et al. (2019) proved that message passing alone can distinguish graphs at most as well as the Weisfeiler-Lehman (1-WL) graph isomorphism test, and that GIN, built on "sum + MLP", reaches that bound. So when "how many" matters (how many contacts, how many neighbours), use the sum; FIG 2 does exactly this: spring forces add up, so a mean would be wrong.

    过平滑的谱解释The spectral view of oversmoothing

    没有可学权重时,\(L\) 层均值聚合就是 \(H^{(L)}=P^LX\),\(P=\tilde D^{-1}\tilde A\)。\(P\) 与对称矩阵 \(\tilde D^{-1/2}\tilde A\tilde D^{-1/2}\) 相似,特征值都是实数,落在 \((-1,1]\) 里(加了自环之后最小的也大于 \(-1\));连通图的最大特征值 \(\lambda_1=1\),对应的特征向量是全 1 向量。把初始特征按特征向量展开:

    Without learnable weights, \(L\) layers of mean aggregation are \(H^{(L)}=P^LX\) with \(P=\tilde D^{-1}\tilde A\). \(P\) is similar to the symmetric matrix \(\tilde D^{-1/2}\tilde A\tilde D^{-1/2}\), so its eigenvalues are real and lie in \((-1,1]\) (with self-loops even the smallest is above \(-1\)); for a connected graph the largest is \(\lambda_1=1\), with the all-ones vector as eigenvector. Expanding the initial features in eigenvectors:

    $$ P^L\mathbf x=c_1\mathbf 1+\sum_{k\ge2}c_k\lambda_k^L\mathbf u_k\ \xrightarrow{L\to\infty}\ c_1\mathbf 1,\qquad \big\|P^L\mathbf x-c_1\mathbf 1\big\|=O\big(|\hl{lam2}{\lambda_2}|^L\big) $$ $$ \mathbf h^{(l+1)}=(1-\alpha)P\,\mathbf h^{(l)}+\alpha\mathbf x\ \ \Rightarrow\ \ \mathbf h^{(\infty)}=\alpha\big(I-(1-\alpha)P\big)^{-1}\mathbf x $$

    所有节点收敛到同一个值 \(c_1\),差别以 \(|\lambda_2|^L\) 的速度消失。FIG 6 的图里 \(\lambda_2=0.919\),\(\lambda_3=0.643\):社区差几乎全部落在 \(\lambda_2\) 对应的特征向量上(它的正负号大致把两个社区分开,这就是谱聚类的道理),所以每层只衰减 8%;社区内的噪声多半落在 \(\lambda_3\) 及以后的特征向量上,衰减快得多。这解释了“先去噪、再抹平”:前几层有益,之后有害。社区之间连得越紧,\(\lambda_2\) 越小,过平滑来得越早。第二行是带初始残差的版本(APPNP,即个性化 PageRank),它的不动点不再是常数向量,所以社区差留了下来。悬停 \(\lambda_2\) 会加粗 FIG 6 里的虚线。真实的 GNN 每层还有权重和非线性,分析更复杂,但同样的现象在实践中很常见;常用的对策是残差连接、归一化,以及干脆不用太多层,让远处的信息通过别的途径(比如一个连到所有节点的“虚拟节点”或全局注意力)传过来。

    All nodes converge to the same value \(c_1\), and the differences die out at the rate \(|\lambda_2|^L\). For the graph of FIG 6, \(\lambda_2=0.919\) and \(\lambda_3=0.643\): the community gap lies almost entirely along the eigenvector of \(\lambda_2\) (whose signs roughly split the two communities, which is the idea behind spectral clustering), so it decays by only 8% per layer, while the noise inside communities lies mostly along \(\lambda_3\) and beyond and decays much faster. That explains "first denoising, then washing out": the first few layers help, later ones hurt. The more tightly the communities are connected, the smaller \(\lambda_2\) and the sooner oversmoothing sets in. The second line is the version with an initial residual (APPNP, i.e. personalized PageRank): its fixed point is no longer a constant vector, so the gap survives. Hovering \(\lambda_2\) thickens the dashed line in FIG 6. Real GNNs also have weights and nonlinearities in every layer, which complicates the analysis, but the same phenomenon is common in practice; the usual remedies are residual connections, normalization, and simply not using many layers, letting distant information arrive another way (a "virtual node" connected to every node, or global attention).

    图本身是模型的一部分The graph is part of the model

    同一组数据可以连成很多种图:按半径连、按 k 近邻连、按网格拓扑连、全部连上。选哪种图就是在选先验:它决定了谁能直接影响谁、要几层才传得到、计算量有多大。学出来的模拟器里,边往往还会随状态变化(两块物体靠近时临时加一条“碰撞边”),图要每一步重新构建。

    The same data can be wired into many graphs: by radius, by k nearest neighbours, by mesh topology, or all-to-all. Choosing the graph is choosing a prior: it decides who can directly influence whom, how many layers information needs, and how much computation it takes. In learned simulators the edges often change with the state too (a temporary "collision edge" is added when two objects come close), so the graph is rebuilt at every step.

    6机器人中的它In robotics

    在机器人里,GNN 主要出现在四类问题上,它们恰好对应本节的几个图:可变形物体与粒子的动力学(FIG 2),可变形态的身体(FIG 3),多机器人和场景里的关系(FIG 4、FIG 5),以及点云这类没有天然顺序的数据。

    In robotics, GNNs show up mainly in four kinds of problems, which line up with the figures of this lesson: dynamics of deformable objects and particles (FIG 2), bodies whose shape varies (FIG 3), relations between robots and between objects in a scene (FIG 4, FIG 5), and data with no natural order, such as point clouds.

    真实系统里In real systems

    学出来的模拟器:Interaction Networks(Battaglia 等,NeurIPS 2016)提出了“边算作用、节点汇总”的结构;Sanchez-Gonzalez 等(ICML 2018)用图网络学习 MuJoCo 里各种身体的动力学,并用于基于模型的控制;GNS(Sanchez-Gonzalez 等,ICML 2020)把流体、沙子、黏性材料表示为粒子,用按半径连接的图和多轮消息传递预测加速度,能推广到比训练时多得多的粒子;它在训练时给输入加随机游走噪声,让模型学会纠正自己滚动中的误差。MeshGraphNets(Pfaff 等,ICLR 2021)在网格上做同样的事,模拟布料和弹性体,并在两块物体靠近时临时加上“世界空间”的边来处理碰撞。 机器人操作可变形物体:DPI-Net(Li 等,ICLR 2019)学习粒子动力学并用于操作刚体、可变形物体和流体;RoboCraft(Shi 等,RSS 2022)用 GNN 粒子模型加模型预测控制(13.4 节)去捏塑面团。 形态学策略:NerveNet(Wang 等,ICLR 2018)把强化学习策略写成身体图上的 GNN,可以迁移到不同大小的身体;Shared Modular Policies(Huang、Mordatch、Pathak,ICML 2020)用一个在所有肢体上共享的模块化策略同时控制多种形态;后来的 AMORPHEUS(Kurin 等,ICLR 2021)发现,在所有肢体之间做注意力的 Transformer 往往比只沿身体图传消息更好:这正是 FIG 5 讲的“图是先验,可能太强”。 多机器人:Li、Gama、Ribeiro、Prorok(IROS 2020)用 GNN 让每台机器人只和通信范围内的邻居交换特征,学出分布式的多机器人路径规划。 场景与点云:三维场景图(15.3 节)的节点和边可以直接交给 GNN 做推理;DGCNN(Wang 等,ACM TOG 2019)在点云上动态地建 k 近邻图再做消息传递;PointNet(Qi 等,CVPR 2017)则是不连边、只做置换不变池化的极端情形。 软件:PyTorch Geometric、DGL 和 Jraph(JAX)都提供“边列表 + 散射求和”的消息传递原语,本页的实现就是这种写法的最小版本。

    Learned simulators: Interaction Networks (Battaglia et al., NeurIPS 2016) introduced the "edges compute effects, nodes aggregate" structure; Sanchez-Gonzalez et al. (ICML 2018) learned the dynamics of various MuJoCo bodies with graph networks and used them for model-based control; GNS (Sanchez-Gonzalez et al., ICML 2020) represents fluids, sand and goop as particles, predicts accelerations with several rounds of message passing on a radius graph, and generalizes to far more particles than it was trained on; during training it adds random-walk noise to its inputs so the model learns to correct its own rollout errors. MeshGraphNets (Pfaff et al., ICLR 2021) does the same on meshes to simulate cloth and elastic bodies, adding temporary "world-space" edges when two objects come close in order to handle collisions. Robots manipulating deformables: DPI-Net (Li et al., ICLR 2019) learns particle dynamics and uses them to manipulate rigid bodies, deformable objects and fluids; RoboCraft (Shi et al., RSS 2022) shapes dough with a GNN particle model plus model predictive control (Lesson 13.4). Morphology policies: NerveNet (Wang et al., ICLR 2018) writes a reinforcement-learning policy as a GNN on the body graph, which transfers to bodies of different sizes; Shared Modular Policies (Huang, Mordatch & Pathak, ICML 2020) control many morphologies at once with one modular policy shared by every limb; the later AMORPHEUS (Kurin et al., ICLR 2021) found that a transformer attending over all limbs often does better than passing messages only along the body graph: exactly the point of FIG 5 that a graph is a prior and can be too strong. Multi-robot: Li, Gama, Ribeiro & Prorok (IROS 2020) use a GNN so that each robot exchanges features only with neighbours in radio range, learning decentralized multi-robot path planning. Scenes and point clouds: the nodes and edges of a 3D scene graph (Lesson 15.3) can be handed directly to a GNN for reasoning; DGCNN (Wang et al., ACM TOG 2019) builds k-nearest-neighbour graphs on point clouds dynamically and passes messages on them; PointNet (Qi et al., CVPR 2017) is the extreme case with no edges at all, only permutation-invariant pooling. Software: PyTorch Geometric, DGL and Jraph (JAX) all provide message-passing primitives of the "edge list + scatter-sum" kind; the implementation on this page is a minimal version of that pattern.

    和 Part IV 的联系也值得一提:15.2 节的位姿图也是一张图,节点是位姿,边是相对测量,但那里的“消息”(雅可比、信息矩阵)是从测量模型推导出来的,求解是一个最小二乘问题。GNN 用同样的图结构,只是让消息规则从数据里学出来。两者可以结合:用 GNN 预测因子图里的测量或权重,再交给经典优化器求解。

    The link to Part IV is worth noting too: the pose graph of Lesson 15.2 is also a graph, with poses as nodes and relative measurements as edges, but there the "messages" (Jacobians, information matrices) are derived from the measurement model and solving it is a least-squares problem. A GNN uses the same kind of graph structure but learns the message rules from data. The two can be combined: a GNN predicts measurements or weights in a factor graph, and a classical optimizer solves it.

    7常见误区Common pitfalls

    误区 1:用平均或最大值,却需要“数个数”Pitfall 1: mean or max aggregation when counts matter

    平均聚合分不清“一个邻居”和“两个一样的邻居”,最大值聚合分不清“一个 b”和“两个 b”(第 5 节)。如果输出依赖于邻居的数量,比如合力、接触点数、一个物体被多少东西压着,就要用求和。反过来,求和的输出会随度数变大,度数差别很大的图(一个中心节点连着几百个邻居)上需要归一化或用平均,否则数值会爆掉。选聚合函数时先问:这个量在物理上是加起来的,还是取平均的?

    Mean aggregation cannot tell "one neighbour" from "two identical neighbours", and max cannot tell "one b" from "two b's" (Section 5). If the output depends on how many neighbours there are, such as a net force, a number of contacts, or how many things press on an object, use the sum. Conversely, a sum grows with the degree, so on graphs whose degrees vary a lot (a hub with hundreds of neighbours) it needs normalization or a mean, or the numbers blow up. When choosing an aggregator ask first: does this quantity add up physically, or is it an average?

    误区 2:想靠堆层数看得更远Pitfall 2: stacking layers to see further

    \(L\) 层只能看 \(L\) 跳,但层数一多就过平滑(FIG 6)。另一个问题叫过度挤压(over-squashing,Alon 与 Yahav,ICLR 2021):远处成指数增长的大量节点,信息全都要挤过少数几条边、压进一个固定长度的向量里。所以需要长程信息时,不要只加层:用残差或初始残差,加一个连到所有节点的虚拟节点,加几条“捷径”边,或者在 GNN 之外再加全局注意力。

    \(L\) layers see only \(L\) hops, but many layers oversmooth (FIG 6). A second problem is over-squashing (Alon & Yahav, ICLR 2021): the exponentially many nodes far away must push all their information through a few edges into one fixed-length vector. So when long-range information is needed, do not just add layers: use residual or initial-residual connections, add a virtual node connected to every node, add a few "shortcut" edges, or add global attention alongside the GNN.

    误区 3:单步误差小,就以为滚动也准Pitfall 3: small one-step error, so the rollout must be accurate

    学出来的模拟器在训练时只看单步,滚动时却把自己的预测当输入,误差会累积,状态还会漂到训练从没见过的区域(FIG 2 的 12 质点绳子,最上面的弹簧超出了训练范围)。FIG 2 的通用模型单步误差只有几个百分点,静止形状却能差好几厘米。常用的对策有:训练时给输入加噪声(GNS),用多步滚动的损失训练,把训练数据的分布做宽,以及像等变模型那样把已知的对称性直接写进结构。评估模拟器时,一定要看长时间滚动的结果,而不只是单步误差。

    A learned simulator is trained on single steps, but in a rollout it consumes its own predictions, so errors accumulate and the state drifts into regions training never saw (FIG 2's 12-mass rope, whose top spring leaves the training range). FIG 2's generic model has a one-step error of a few percent yet a resting shape several centimetres off. The usual remedies: add noise to the inputs during training (GNS), train with multi-step rollout losses, widen the training distribution, and build known symmetries into the structure, as the equivariant model does. Always judge a simulator by long rollouts, not just by its one-step error.

    误区 4:输入用绝对坐标Pitfall 4: absolute coordinates as input

    如果把每个质点的绝对位置 \(\mathbf x_i\) 当节点特征,网络就得在每个位置分别学一遍物理:在训练区域外(比如把钉点拖到别处),预测会失效。物理定律只依赖相对位置,所以应该把 \(\mathbf x_j-\mathbf x_i\) 放在边上(平移不变),把真正属于节点本身的量(速度、质量、材料类型)放在节点上。同理,重力这种有方向的外场是“破坏旋转对称”的,要作为单独的输入给出,不能指望等变结构自己猜出来。

    With each mass's absolute position \(\mathbf x_i\) as a node feature, the network must learn the physics separately at every location, and outside the training region (drag the pin somewhere else) the predictions fail. Physical laws depend only on relative positions, so \(\mathbf x_j-\mathbf x_i\) belongs on the edges (translation invariance), and only what truly belongs to a node (velocity, mass, material type) belongs on the node. In the same way, a directed external field such as gravity breaks the rotational symmetry and must be supplied as a separate input; an equivariant structure cannot be expected to guess it.

    误区 5:给节点加编号来“区分”它们Pitfall 5: adding node indices to tell nodes apart

    对称的节点得到相同的输出(FIG 3 的讨论),于是有人把节点编号的独热向量加进特征。这确实能区分节点,但同时破坏了置换等变:模型又依赖编号了,也就无法迁移到大小不同的图。更好的做法是加有物理意义、与编号无关的特征:关节类型、在身体坐标系里的位置、到根节点的深度、左右侧的标志;如果需要真正的“位置编码”,用拉普拉斯特征向量之类由图结构算出的量。

    Symmetric nodes get identical outputs (the discussion after FIG 3), so some people add a one-hot node index to the features. That does tell nodes apart, but it also destroys permutation equivariance: the model depends on the numbering again and no longer transfers to graphs of other sizes. Better: add features that have physical meaning and do not depend on the numbering, such as joint type, position in the body frame, depth from the root, or a left/right flag; if real "positional encodings" are needed, use quantities computed from the graph structure, such as Laplacian eigenvectors.

    8小练习Check yourself

    1. 一个 3 层的 GNN,节点 \(i\) 的输出可能受哪些节点的输入特征影响?1. In a 3-layer GNN, the input features of which nodes can affect the output at node \(i\)?
    每层信息走一跳,并且每层都保留节点自己的状态,所以 3 层之后 \(i\) 汇集了 0、1、2、3 跳内所有节点的信息:这是它的感受野 \(\mathcal N_3(i)\)(FIG 1 里的紫色区域)。超过 3 跳的节点无论特征怎样变,都影响不到它。选项 B 只有在图的半径不超过 3 时才成立。Information moves one hop per layer and every layer keeps the node's own state, so after 3 layers \(i\) has gathered information from every node within 0, 1, 2 or 3 hops: its receptive field \(\mathcal N_3(i)\) (the purple region in FIG 1). Nodes further than 3 hops cannot affect it however their features change. Option B holds only if no node is more than 3 hops from \(i\).
    2. 把一张图的节点重新编号后再输入同一个 GNN。节点级输出和“把所有节点输出求和”的图级读出会怎样?2. A graph's nodes are renumbered and fed to the same GNN. What happens to the node-level outputs and to the graph-level readout "sum of all node outputs"?
    这是置换等变 \(F(PX,PAP^\top)=PF(X,A)\) 和置换不变 \(r(PX,PAP^\top)=r(X,A)\),对任何权重都成立,因为每一步只用邻居多重集和与顺序无关的聚合(FIG 3 的蓝条)。选项 D 错在这是结构性质,与权重无关。This is permutation equivariance \(F(PX,PAP^\top)=PF(X,A)\) and invariance \(r(PX,PAP^\top)=r(X,A)\), which hold for any weights because every step uses only the multiset of neighbours and an order-free aggregation (the blue bars in FIG 3). Option D is wrong because it is a structural property, independent of the weights.
    3. 在 FIG 4 的“跟随领队”任务上,单层 GCN 学不会、单层 GAT 学得会。根本原因是什么?3. On FIG 4's "follow the leader" task a single-layer GCN fails and a single-layer GAT succeeds. What is the root cause?
    GCN 确实看得到领队的特征(选项 B 不对),但它只能以固定份额 \(1/(k+1)\) 混进平均值,和其他跟随者的 \(s\) 搅在一起,而且份额随邻居数 \(k\) 变化。GAT 多出的只是一个很小的打分层(选项 A 不是关键),它让权重取决于内容,这正是注意力的意义。The GCN does see the leader's features (so option B is wrong), but only as a fixed share \(1/(k+1)\) of an average, mixed with the other followers' \(s\), and that share changes with the number of neighbours \(k\). All the GAT adds is a tiny scoring layer (option A is not the point); it makes the weights depend on content, which is what attention is for.
    4. 节点 u 有两个邻居,特征都是 \(a\);节点 v 只有一个邻居,特征也是 \(a\)。哪种聚合能让 GNN 区分 u 和 v 的邻域?4. Node u has two neighbours, both with feature \(a\); node v has one neighbour, also with feature \(a\). Which aggregator lets a GNN tell the neighbourhoods of u and v apart?
    求和给出 \(2\phi(a)\) 对 \(\phi(a)\),可以区分;平均和最大值都给出 \(\phi(a)\),分不开。这就是 GIN(Xu 等,2019)选择“求和 + MLP”的原因,也是 FIG 2 用求和的原因:两根弹簧的力本来就该加起来。(只要 \(\phi(a)\ne0\),求和就能区分。)The sum gives \(2\phi(a)\) versus \(\phi(a)\) and tells them apart; mean and max both give \(\phi(a)\) and cannot. This is why GIN (Xu et al., 2019) chooses "sum + MLP", and why FIG 2 sums: the forces of two springs should add. (The sum distinguishes them as long as \(\phi(a)\ne0\).)
    5. 在一张连通图上反复做均值聚合(没有可学权重)。层数趋于无穷时节点特征会怎样,速度由什么决定?5. Mean aggregation (no learnable weights) is applied over and over on a connected graph. What happens to the node features as the number of layers goes to infinity, and what sets the speed?
    \(P=\tilde D^{-1}\tilde A\) 的最大特征值是 1,对应全 1 向量,其余特征值的绝对值都小于 1,所以 \(P^L\mathbf x\to c_1\mathbf 1\),偏差按第二大特征值的 \(|\lambda_2|^L\) 衰减:这就是过平滑。选项 D 描述的是社区差,它确实是最后才消失的部分(沿 \(\lambda_2\) 的方向),但仍会以 \(\lambda_2^L\) 消失;FIG 6 里 \(\lambda_2=0.919\),54 层后社区差不到 1%。The largest eigenvalue of \(P=\tilde D^{-1}\tilde A\) is 1, with the all-ones vector, and all the others have absolute value below 1, so \(P^L\mathbf x\to c_1\mathbf 1\) with deviations decaying like \(|\lambda_2|^L\): oversmoothing. Option D describes the community gap, which is indeed the last part to go (it lies along \(\lambda_2\)), but it still disappears like \(\lambda_2^L\); in FIG 6, \(\lambda_2=0.919\) and the gap is below 1% after 54 layers.

    9延伸阅读Further reading

    • F. Scarselli, M. Gori, A. C. Tsoi, M. Hagenbuchner & G. Monfardini, The Graph Neural Network Model, IEEE Transactions on Neural Networks, 2009 — 最早的 GNN 形式之一one of the first formulations of GNNs
    • J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals & G. E. Dahl, Neural Message Passing for Quantum Chemistry, ICML 2017 — 把各种 GNN 统一成消息传递框架unifies many GNNs as message passing
    • T. N. Kipf & M. Welling, Semi-Supervised Classification with Graph Convolutional Networks, ICLR 2017 — GCNthe GCN
    • P. Veličković, G. Cucurull, A. Casanova, A. Romero, P. Liò & Y. Bengio, Graph Attention Networks, ICLR 2018 — GAT:边上的注意力GAT: attention on edges
    • K. Xu, W. Hu, J. Leskovec & S. Jegelka, How Powerful are Graph Neural Networks?, ICLR 2019 — 与 WL 测试的关系,求和聚合与 GINthe link to the WL test, sum aggregation and GIN
    • Q. Li, Z. Han & X.-M. Wu, Deeper Insights into Graph Convolutional Networks for Semi-Supervised Learning, AAAI 2018 — 把 GCN 看成拉普拉斯平滑,指出过平滑GCN as Laplacian smoothing, and oversmoothing
    • J. Klicpera (Gasteiger), A. Bojchevski & S. Günnemann, Predict then Propagate: Graph Neural Networks meet Personalized PageRank, ICLR 2019 — APPNP 与初始残差APPNP and the initial residual
    • P. W. Battaglia, R. Pascanu, M. Lai, D. Rezende & K. Kavukcuoglu, Interaction Networks for Learning about Objects, Relations and Physics, NeurIPS 2016 — 学出来的物理learned physics
    • A. Sanchez-Gonzalez, J. Godwin, T. Pfaff, R. Ying, J. Leskovec & P. W. Battaglia, Learning to Simulate Complex Physics with Graph Networks, ICML 2020 — GNS:粒子模拟器与噪声注入GNS: particle simulators and noise injection
    • T. Pfaff, M. Fortunato, A. Sanchez-Gonzalez & P. W. Battaglia, Learning Mesh-Based Simulation with Graph Networks, ICLR 2021 — MeshGraphNets:布料与弹性体MeshGraphNets: cloth and elastic bodies
    • T. Wang, R. Liao, J. Ba & S. Fidler, NerveNet: Learning Structured Policy with Graph Neural Networks, ICLR 2018 — 身体图上的策略policies on the body graph
    • V. G. Satorras, E. Hoogeboom & M. Welling, E(n) Equivariant Graph Neural Networks, ICML 2021 — 把旋转、平移等变性写进消息(FIG 2 等变模型的一般形式)rotation and translation equivariance built into messages (the general form of FIG 2's equivariant model)
    • P. W. Battaglia et al., Relational Inductive Biases, Deep Learning, and Graph Networks, arXiv 2018 — “图网络”框架的综述a survey of the "graph network" framework
    • W. L. Hamilton, Graph Representation Learning, Morgan & Claypool, 2020 — 入门教材an introductory textbook
    • M. M. Bronstein, J. Bruna, T. Cohen & P. Veličković, Geometric Deep Learning: Grids, Groups, Graphs, Geodesics, and Gauges, arXiv 2021 — 用对称性统一 CNN、GNN 与 TransformerCNNs, GNNs and transformers unified through symmetry