GCN模块的实现比较简单,在giuhub上看到两种实现,轻微不同

实现一:https://github.com/ycszen/pytorch-segmentation/blob/master/gcn.py

class GCN(nn.Module):
def __init__(self, inplanes, planes, ks=7):
super(GCN, self).__init__()
self.conv_l1 = nn.Conv2d(inplanes, planes, kernel_size=(ks, 1),
padding=(ks/2, 0)) self.conv_l2 = nn.Conv2d(planes, planes, kernel_size=(1, ks),
padding=(0, ks/2))
self.conv_r1 = nn.Conv2d(inplanes, planes, kernel_size=(1, ks),
padding=(0, ks/2))
self.conv_r2 = nn.Conv2d(planes, planes, kernel_size=(ks, 1),
padding=(ks/2, 0)) def forward(self, x):
x_l = self.conv_l1(x)
x_l = self.conv_l2(x_l) x_r = self.conv_r1(x)
x_r = self.conv_r2(x_r) x = x_l + x_r return x

实现二:https://github.com/ogvalt/large_kernel_matters/blob/master/scripts/model.py

class GCN(nn.Module):
def __init__(self, inchannels, channels=21, k=3):
super(GCN, self).__init__() self.conv_l1 = Conv2D(in_channels=inchannels, out_channels=channels, kernel_size=(k, 1), padding='same')
self.conv_l2 = Conv2D(in_channels=channels, out_channels=channels, kernel_size=(1, k), padding='same') self.conv_r1 = Conv2D(in_channels=inchannels, out_channels=channels, kernel_size=(1, k), padding='same')
self.conv_r2 = Conv2D(in_channels=channels, out_channels=channels, kernel_size=(k, 1), padding='same') def forward(self, x):
x1 = self.conv_l1(x)
x1 = self.conv_l2(x1) x2 = self.conv_r1(x)
x2 = self.conv_r2(x2) out = x1 + x2 return out

两种实现不同之处在padding的方式,一种是设定值,一种是自动的。不过我发现pytorch0.4.0是不支持对padding关键字参数传入字符串的,另外,我自己写了一个3D版的,不知道对否。

class GCN(nn.Module):
def __init__(self, inplanes, planes, ks=7):
super(GCN, self).__init__()
self.conv_l1 = nn.Conv3d(inplanes, planes, kernel_size=(ks, 1, 1),
padding=(ks/2, 0, 0))
self.conv_l2 = nn.Conv3d(planes, planes, kernel_size=(1, ks, 1),
padding=(0, ks/2, 0))
self.conv_l3 = nn.Conv3d(planes, planes, kernel_size=(1, 1, ks),
padding=(0, 0, ks/2)) self.conv_c1 = nn.Conv3d(inplanes, planes, kernel_size=(1, ks, 1),
padding=(0, ks/2, 0))
self.conv_c2 = nn.Conv3d(planes, planes, kernel_size=(1, 1, ks),
padding=(0, 0, ks/2))
self.conv_c3 = nn.Conv3d(planes, planes, kernel_size=(ks, 1, 1),
padding=(ks/2, 0, 0)) self.conv_r1 = nn.Conv3d(inplanes, planes, kernel_size=(1, 1, ks),
padding=(0, 0, ks/2))
self.conv_r2 = nn.Conv3d(planes, planes, kernel_size=(ks, 1, 1),
padding=(ks/2, 0, 0))
self.conv_r3 = nn.Conv3d(planes, planes, kernel_size=(1, ks, 1),
padding=(0, ks/2, 0)) def forward(self, x):
x_l = self.conv_l1(x)
x_l = self.conv_l2(x_l)
x_l = self.conv_l3(x_l) x_c = self.conv_c1(x)
x_c = self.conv_c2(x_c)
x_c = self.conv_c3(x_c) x_r = self.conv_r1(x)
x_r = self.conv_r2(x_r)
x_r = self.conv_r3(x_r)
x = x_l + x_r + x_c return x

  

【语义分割】large kernel matters中GCN模块的pytorch实现的更多相关文章

  1. Large Kernel Matters —— Improve Semantic Segmentation by Global Convolutional Network(GCN全局卷积网络)

    作者认为语义分割的两个挑战是分类和定位,而这两个挑战又是比较对立的.对于分类问题,模型需要有变形和旋转不变形,而对于定位问题,模型有需要对变形敏感. 提出的GCN遵循两个主要原则: 1.对定位问题,模 ...

  2. 【语义分割】PSPNet中PSP模块的pytorch实现

    github地址:https://github.com/Lextal/pspnet-pytorch/blob/master/pspnet.py PSP模块示意图如下 代码如下 class PSPMod ...

  3. 语义分割(semantic segmentation) 常用神经网络介绍对比-FCN SegNet U-net DeconvNet,语义分割,简单来说就是给定一张图片,对图片中的每一个像素点进行分类;目标检测只有两类,目标和非目标,就是在一张图片中找到并用box标注出所有的目标.

    from:https://blog.csdn.net/u012931582/article/details/70314859 2017年04月21日 14:54:10 阅读数:4369 前言 在这里, ...

  4. 利用NVIDIA-NGC中的MATLAB容器加速语义分割

    利用NVIDIA-NGC中的MATLAB容器加速语义分割 Speeding Up Semantic Segmentation Using MATLAB Container from NVIDIA NG ...

  5. 笔记:基于DCNN的图像语义分割综述

    写在前面:一篇魏云超博士的综述论文,完整题目为<基于DCNN的图像语义分割综述>,在这里选择性摘抄和理解,以加深自己印象,同时达到对近年来图像语义分割历史学习和了解的目的,博古才能通今!感 ...

  6. CVPR2020:4D点云语义分割网络(SpSequenceNet)

    CVPR2020:4D点云语义分割网络(SpSequenceNet) SpSequenceNet: Semantic Segmentation Network on 4D Point Clouds 论 ...

  7. 使用LabVIEW实现基于pytorch的DeepLabv3图像语义分割

    前言 今天我们一起来看一下如何使用LabVIEW实现语义分割. 一.什么是语义分割 图像语义分割(semantic segmentation),从字面意思上理解就是让计算机根据图像的语义来进行分割,例 ...

  8. 语义分割Semantic Segmentation研究综述

    语义分割和实例分割概念 语义分割:对图像中的每个像素都划分出对应的类别,实现像素级别的分类. 实例分割:目标是进行像素级别的分类,而且在具体类别的基础上区别不同的实例. 语义分割(Semantic S ...

  9. TensorFlow中的语义分割套件

    TensorFlow中的语义分割套件 描述 该存储库用作语义细分套件.目标是轻松实现,训练和测试新的语义细分模型!完成以下内容: 训练和测试方式 资料扩充 几种最先进的模型.轻松随插即用 能够使用任何 ...

随机推荐

  1. 如何查询centos、Debian服务器、查看系统内核版本,系统版本,32位还是64位

    查看centos内核的版本: 1)[root@localhost ~]# cat /proc/version Linux version 2.6.18-194.el5 (mockbuild@build ...

  2. 【总结整理】如何判断伪需求(摘自pmcafe)

    1.客户不会直接提需求,都是给解决方案,所以得到用户的反馈之后,先反推一下是很必要的,为什么客户会有这样的方案 总结:方案不合适 例如:客户只会说我要快马,反推一下,其实客户是想要更快,这样的话,解决 ...

  3. 3-No resource found that matches the given name 'Theme.AppCompat.Light 的完美解决方案

    转载:http://www.360doc.com/content/15/0316/15/9200790_455576135.shtml 由于我在配置安卓环境时也碰到了类似问题,用这篇博客解决了主要问题 ...

  4. Ubuntu14.04下安装glog

    下载原始代码编译 1. Clone Source Code  glog git clone https://github.com/google/glog 2. Install dependencies ...

  5. ROS naviagtion analysis: costmap_2d--LayeredCostmap

    博客转自:https://blog.csdn.net/u013158492/article/details/50490490 在数据成员中,有两个重要的变量:Costmap2D costmap_和 s ...

  6. Gnu C API使用指南

    1)posix_fadvise http://blog.yufeng.info/archives/1917 2)fts系列 http://www.cnblogs.com/patientAndPersi ...

  7. Django--初始化

    1.Django介绍 它是一个WEB框架 Django--大而全 tornado.flask--小而精 2.Django安装 https://www.djangoproject.com/downloa ...

  8. PHP加密与解密

    password_hash ( string $password , integer $algo [, array $options ] ) 加密,生成60位得字符串 $algo:一个用来在散列密码时 ...

  9. Browser

    浏览器中关于事件的那点事儿 作者: 顽Shi  发布时间: 2014-02-01 20:22  阅读: 7830 次  推荐: 25   原文链接   [收藏]   摘要:事件在Web前端领域有很重要 ...

  10. Android Bundle传递数据

    1.传递普通数据 Intent intent=new Intent(MainActivity.this,TwoActivity.class); Bundle bundle=new Bundle(); ...