博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
后RCNN时代的物体检测及实例分割进展
阅读量:5129 次
发布时间:2019-06-13

本文共 2848 字,大约阅读时间需要 9 分钟。

https://mp.weixin.qq.com/s?__biz=MzA3MzI4MjgzMw==&mid=2650736740&idx=3&sn=cdce446703e69b47cf48f12b3d451afc&chksm=871acc1ab06d450ccde3148df96436c98adb2de3b6a34559b95af322c5186513460329dc20bd&pass_ticket=fRFENbG47o6E12opTV0zxlHKhCFDxvRrZMSQpTw%2BcZ9h0Z38WqvICgwk5ynPYCBm#rd后RCNN时代的物体检测及实例分割进展

def conv3x3(in_channels, out_channels, stride=1):    return nn.Conv2d(in_channels, out_channels, kernel_size=3,                     stride=stride, padding=1, bias=False)class ResidualBlock(nn.Module):    def __init__(self, in_channels, out_channels, stride=1, downsample=None):        super(ResidualBlock, self).__init__()        self.conv1 = conv3x3(in_channels, out_channels, stride)        self.bn1 = nn.BatchNorm2d(out_channels)        self.relu = nn.ReLU(inplace=True)        self.conv2 = conv3x3(out_channels, out_channels, stride)        self.bn2 = nn.BatchNorm2d(out_channels)        self.downsample = downsample        def forward(self, x):        residual = x        out = self.conv1(x)        out = self.bn1(out)        out = self.relu(out)        out = self.conv2(out)        out = self.bn2(out)        if self.downsample:            residual = self.downsample(residual)                out += residual        out = self.relu(out)        return outclass ResNet(nn.Module):    def __init__(self, block, layers, num_classes=10):        super(ResNet, self).__init__()        self.in_channels = 16        self.conv =  conv3x3(1, 16)        self.bn = nn.BatchNorm2d(16)        #self.relu = nn.Relu(inplace=True)        self.relu = nn.ReLU(inplace=True)        self.layers1 = self.make_layers(block, 16, layers[0])        self.layers2 = self.make_layers(block, 32, layers[1])        self.layers3 = self.make_layers(block, 64, layers[2])        self.avg_pool = nn.AvgPool2d(8)        self.fc = nn.Linear(64, num_classes)            def make_layers(self, block, out_channels, blocks, stride=1):        downsample = None        if(stride!=1) or (self.in_channels != out_channels):            downsample = nn.Sequential(conv3x3(self.in_channels, out_channels, stride = stride),                                      nn.BatchNorm2d(out_channels))                    layers = []        layers.append(block(self.in_channels, out_channels, stride, downsample))        self.in_channels = out_channels        for i in range(blocks):            layers.append(block(self.in_channels, out_channels, stride, downsample))                return nn.Sequential(*layers)        def forward(self, x):        out = self.conv(x)        out = self.bn(out)        out = self.relu(out)        out = self.layers1(out)        out = self.layers2(out)        out = self.layers3(out)        out = self.avg_pool(out)        out = self.fc(out)                return outresnet = ResNet(ResidualBlock, layers=[2, 2, 2, 2])
View Code

 

转载于:https://www.cnblogs.com/573177885qq/p/8417152.html

你可能感兴趣的文章
假如女人是一种编程语言,你会更喜欢哪一种
查看>>
debian 64位系统中添加对32位的支持
查看>>
基于CentOS6.5或Ubuntu14.04下Suricata里搭配安装 ELK (elasticsearch, logstash, kibana)(图文详解)...
查看>>
如果遇到Hadoop集群正常,MapReduce作业运行出现错误,如何来查看作业运行日志(图文详解)...
查看>>
硬件驱动程序的知识点滴
查看>>
车牌号码正则表达式
查看>>
Tesseract 4 自行构建支持双引擎的tessdata 文件
查看>>
Find and kill the dead lock process
查看>>
CListCtrl 的应用
查看>>
mongodb
查看>>
合并指定表格指定行的相同文本的相邻单元格
查看>>
双屏幕,鼠标移动设置
查看>>
【BZOJ-3809】Gty的二逼妹子序列 分块 + 莫队算法
查看>>
《Entity Framework 6 Recipes》中文翻译——第十章EntityFramework存储过程处理(四)...
查看>>
收缩自编码器(CAE)
查看>>
AVL平衡树的插入例程
查看>>
Android Studio怎么删除项目
查看>>
shell变量自增 || Python脚本接收参数
查看>>
关于python安装lxml插件的问题
查看>>
Exp7 网络欺诈防范
查看>>