Global Convolutional Network(GCN)网络模型

目录

资料

网络模型分析

GCN设计思想来源

整体网络结构图

GCN架构

Boundary Refinement结构

讨论

Reference 


资料

论文地址:https://arxiv.org/pdf/1703.02719.pdf

pytorch代码:pytorch-semantic-segmentation/gcn.py at master · zijundeng/pytorch-semantic-segmentation · GitHub 

论文贡献:

1.提出了GCN架构;

2.引入Boundry Refine对分割边界进一步细化达到更优效果;

3.在PASCAL VOC 2012(82.2%) and Cityscapes(76.9%)取得state-of-the-art.

网络模型分析


如果拆解语义分割任务的话,Semantic Segmentation = classification + localization。但识别和定位两个任务的要义是矛盾的,即识别任务要求模型对各种变换不敏感(例如翻转和旋转),定位任务要求对变换敏感,可以精确分割像素。

GCN设计思想来源

1.从定位的角度来看,模型结构应该是全卷积的以保持定位性能,并且不应该使用全连接或全局池化层,因为这些层会丢弃定位信息;

2.从分类的角度来看,网络架构中应该采用大的内核大小,

PyG(Torch Geometric)是一个用于图神经网络(Graph Neural Networks, GNNs)的Python库,它是基于PyTorch构建的。如果你想使用PyG搭建GCN(Graph Convolutional Network网络,首先需要安装`torch_geometric`库。以下是一个简单的步骤概述: 1. **安装**: ```bash pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/torch_stable.html pip install torch-scatter -f https://github.com/rusty1s/pytorch_scatter/blobs/main/dist/ pip install torch-sparse -f https://github.com/rusty1s/pytorch_sparse/blobs/main/dist/ pip install torch-cluster -f https://github.com/rusty1s/pytorch_cluster/blobs/main/dist/ pip install torch-geometric ``` 2. **导入所需模块**: ```python import torch from torch_geometric.nn import GCNConv, global_mean_pool ``` 3. **构建数据结构**: 使用`torch_geometric.data.Data`类来创建图的数据结构,包括节点特征和边的信息。 4. **定义模型**: ```python class GCN(torch.nn.Module): def __init__(self, in_channels, hidden_channels, out_channels): super(GCN, self).__init__() self.conv1 = GCNConv(in_channels, hidden_channels) self.conv2 = GCNConv(hidden_channels, out_channels) def forward(self, data): x, edge_index = data.x, data.edge_index x = F.relu(self.conv1(x, edge_index)) x = self.conv2(x, edge_index) return global_mean_pool(x, data.batch) ``` 5. **训练和预测**: 定义损失函数、优化器,并通过`DataLoader`加载数据进行训练。 ```python model = GCN(...).to(device) optimizer = torch.optim.Adam(model.parameters(), lr=0.01) for epoch in range(100): # 假设这是训练循环 optimizer.zero_grad() output = model(data) loss = F.nll_loss(output[data.train_mask], data.y[data.train_mask]) loss.backward() optimizer.step() # 预测阶段 with torch.no_grad(): pred = model(data) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值