Graph Convolutional Neural Network - Spatial Convolution 图卷积神经网络 — 空域卷积详解

本文介绍了图卷积神经网络(ConvGNNs),特别是空域卷积方法。ConvGNNs将卷积操作从网格数据扩展到图数据,通过节点特征聚合和邻居特征来生成节点表示。文章对比了ConvGNNs与RecGNNs,重点讨论了Message Passing Neural Network (MPNN)、GraphSAGE和PATCHY-SAN等模型的工作原理和特点。

往期文章链接目录

Note

This is the second post of the Graph Neural Networks (GNNs) series.

Convolutional graph neural networks (ConvGNNs)

Convolutional graph neural networks (ConvGNNs) generalize the operation of convolution from grid data to graph data. The main idea is to generate a node v v v’s representation by
aggregating its own features x v \mathbf{x}_{v} xv and neighbors’ features x u \mathbf{x}_{u} xu, where u ∈ N ( v ) u \in N(v) uN(v)
. Different from RecGNNs, ConvGNNs stack fixed number of multiple graph convolutional layers with different weights to extract high-level node representations.

ConvGNNs fall into two categories:

  • spatial-based GCN: Spatial-based approaches inherit ideas from RecGNNs to define graph convolutions by information propagation.

  • spectral-based GCN: Spectral based approaches define graph convolutions by introducing filters from the perspective of graph signal processing where the graph convolutional operation is interpreted as removing noises from graph signals.

Spatial-based methods have developed rapidly recently due to its attractive efficiency, flexibility, and generality. In this post, we mainly focus on spatial-based GCN and leave spectral-based GCN to the next post. Let’s get started.

GCN Framework

As shown in the figure above, the input of GCN is the entire graph. In each convolution layer, a convolution operation is performed on the neighbors of each node, and the center node representation is updated with the result of the convolution. Then an activation function such as ReLU is used before going through the next layer of convolution layer. The above process continues until the number of layers reaches the expected depth (a hyper-parameter).

GCN v.s. RecGNN

The main difference between GCN and RecGNN is that each convolutional layer of GCN has unique weights, and, on the other hand, in RecGNN the weights of each layer are shared.

What is Convolution

In mathematics, convolution is a mathematical operation on two functions f f f and g g g that produces a third function ( f ∗ g ) (f∗g) (fg) expressing how the shape of one is modified by the other.

The term convolution is defined as the integral of the product of the two functions after one is reversed and shifted. The mathematical definition is the following:

( f ∗ g ) ( t ) = ∫ − ∞ ∞ f ( τ ) g ( t − τ ) ( continuous ) ( f ∗ g ) ( t ) = ∑ τ = − ∞ ∞ f ( τ ) g ( t − τ ) ( discrete ) \begin{array}{c} (f * g)(t)=\int_{-\infty}^{\infty} f(\tau) g(t-\tau) \quad (\text {continuous}) \\ (f * g)(t)=\sum_{\tau=-\infty}^{\infty} f(\tau) g(t-\tau) \quad(\text {discrete}) \end{array} (fg)(t)=f(τ)g(tτ)(continuous)(fg)(t)=τ=f(τ)g(tτ)(discrete)

The convolution formula can be described as a weighted average of the function f ( τ ) f(\tau) f(τ) at the moment t t t where the weighting is given by g ( − τ ) g(-\tau) g(τ) simply shifted by amount t t t. As t t t changes, the weighting function emphasizes different parts of the input function.

As the figure shown above, the filter is moved over by one pixel and this process is repeated until all of the possible locations in the image are filtered. At each step, the convolution takes the weighted average of pixel values of the center pixel along with its neighbors. Since the center pixel is changing at each time step, the convolution is emphasizing on different parts of the image.

Spatial-based ConvGNNs

Analogous to the convolutional operation of a conventional CNN on an image, spatial-based methods define graph convolutions based on a node’s spatial relations.

Images can be considered as a special form of graph with each pixel representing a node. Each pixel is directly connected to its nearby pixels, as illustrated in the figure above (left). A filter is applied to a 3 × 3 3 \times 3 3×3 patch by taking the weighted average of pixel values of the central node and its neighbors across each channel.

Similarly, the spatial-based graph convolutions convolve the central node’s representation with its neighbors’ representations to derive the updated representation for the central node. From another perspective, spatial-based ConvGNNs share the same idea of information propagation/message passing with RecGNNs. The spatial graph convolutional operation essentially propagates node information along edges.

Message Passing Neural Network (MPNN)

Introduction to MPNN

Message Passing Neur

### 时序卷积网络 TCN 与时序图神经网络 GNN 的比较及结合应用 #### 比较分析 时序卷积网络(Temporal Convolutional Network, TCN)和图神经网络Graph Neural Network, GNN)在处理时间序列数据时具有不同的特点。TCN主要通过因果卷积、膨胀卷积等技术捕捉时间序列中的时序特征[^3],而GNN则专注于建模空间依赖关系,例如变量之间的相互作用或网络结构中的节点关系[^1]。 - **TCN 的优势**:TCN在处理长序列时表现出色,具备并行化能力、较长的感受野以及稳定的梯度传播特性,能够有效避免循环神经网络(RNN)和长短期记忆网络(LSTM)中常见的梯度消失和梯度爆炸问题。 - **GNN 的优势**:GNN擅长捕捉复杂的空间依赖关系,尤其是当数据以图的形式表示时。例如,在交通预测任务中,GNN可以通过图卷积操作聚合相邻节点的信息,从而建模路网中的空间依赖性[^1]。 尽管两者各有侧重,但它们并非完全独立,而是可以结合使用以同时捕捉时间和空间维度的特征。 --- #### 结合方式 为了更好地建模时空数据,TCN 和 GNN 可以通过以下几种方式进行结合: 1. **空间与时间分离建模** 在这种方法中,GNN首先用于捕捉空间依赖关系,然后将结果传递给TCN以建模时间维度上的特征。例如,STGCN(Spatio-Temporal Graph Convolutional Networks)结合了图卷积层(如ChebConv)和时间卷积层,分别用于提取空间和时间模式[^1]。 ```python import torch import torch.nn as nn from pytorch_modules import SpatialConv, TemporalConv class STGCN(nn.Module): def __init__(self, in_channels, out_channels, num_nodes): super(STGCN, self).__init__() self.spatial_conv = SpatialConv(in_channels, out_channels, num_nodes) self.temporal_conv = TemporalConv(out_channels, out_channels) def forward(self, x, adj_matrix): x = self.spatial_conv(x, adj_matrix) # 空间建模 x = self.temporal_conv(x) # 时间建模 return x ``` 2. **联合建模** 联合建模方法直接在单个网络中同时捕捉时间和空间特征。例如,扩散图卷积(Diffusion Graph Convolution)可以与TCN结合,形成一种新的混合架构,其中扩散过程模拟时间动态变化,而TCN负责捕捉长期时间依赖性[^4]。 3. **多尺度建模** 多尺度建模通过堆叠多个GNN和TCN层来捕捉不同尺度上的时空特征。例如,SLCNN结合了全局和局部卷积操作,利用ChebConv和局部消息传递机制分别捕捉粗粒度和细粒度的空间关系[^1]。 --- #### 应用场景 TCN 和 GNN 的结合在许多实际应用场景中表现出色,例如: - **交通流量预测**:利用GNN建模路网中的空间依赖关系,并通过TCN捕捉交通流量的时间变化趋势[^1]。 - **电力负荷预测**:电力系统中的节点之间存在复杂的相互作用,GNN可用于建模这些空间关系,而TCN则用于捕捉负荷随时间的变化模式。 - **气象预测**:气象数据通常具有强烈的时空相关性,GNN可以建模地理区域之间的空间依赖性,而TCN则捕捉天气现象的时间演化过程。 ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值