DataScience 板


LINE

※ 引述《Haikyuu (!!)》之铭言: : convolution with stride跟pooling都是将feature map变小张的方法 : 例如convolution with stride=2的输出大小相当於2x2的pooling的输出大小 : 那想请问这两者的使用上是怎麽取舍的呢? : 我认为convolution丢掉的资讯量比较少,所以DCGAN才使用convolution而非pooling : 来使Discriminator可以分辨细微差异 首先,Striving for simplicity: The all convolutional net提到 'We find that max-pooling can simply be replaced by a convolutional layer with increased stride without loss in accuracy on several image recognition benchmarks' 在多个 image classification benchmark上 使用convolution with stride=2替换2x2 pooling并没有损失acc Ref: https://goo.gl/Q3c9i7 第二,用convolution with stride会比较快, 以下是我使用pytorch0.4 & python3.6测试的结果 使用CPU intel i5-6500 1. conv + 2*2maxpool = 0.13秒 2. conv with stride2 = 0.009秒 使用GPU gtx1080 1. conv + 2*2maxpool = 0.046秒 2. conv with stride2 = 0.00069 batch size = 64 image size = 100*100 input channel = 3 output channel = 64 kernel size = 3 ### CPU import time import torch a = torch.rand(64,3,100,100) conv = torch.nn.Conv2d(3, 64, 3) pool = torch.nn.MaxPool2d(2) start = time.time() out1 = pool(conv(a)) print(time.time()-start) conv2 = torch.nn.Conv2d(3, 64, 3, stride=2) start = time.time() out2 = conv2(a) print(time.time()-start) ### GPU import time import torch import torch.nn as nn import torch.nn.functional as F class ConvPool(nn.Module): def __init__(self): super().__init__() self.conv = torch.nn.Conv2d(3, 64, 3) self.pool = torch.nn.MaxPool2d(2) def forward(self, x): out = self.pool(F.relu(self.conv(x))) return out class ConvStride(nn.Module): def __init__(self): super().__init__() self.conv = torch.nn.Conv2d(3, 64, 3, stride=2) def forward(self, x): out = F.relu(self.conv(x)) return out a = torch.rand(64,3,100,100).to('cuda') conv_pool = ConvPool().to('cuda') start = time.time() out1 = conv_pool(a) print(time.time()-start) conv_stride = ConvStride().to('cuda') start = time.time() out2 = conv_stride(a) print(time.time()-start) --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 211.72.69.157
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/DataScience/M.1529981935.A.218.html ※ 编辑: robert780612 (211.72.69.157), 06/26/2018 11:00:56 ※ 编辑: robert780612 (211.72.69.157), 06/26/2018 11:01:16
1F:推 goldflower: 推实验 06/26 14:21
※ 编辑: robert780612 (211.72.69.157), 06/26/2018 16:37:16
2F:推 aszx4510: 感谢教学 06/26 20:40
3F:推 Mchord: 这篇是只有在classification benchmark,但对detection和s 06/26 22:41
4F:→ Mchord: egmentation就不会是没有loss 06/26 22:41
5F:→ robert780612: 感谢楼上补充 06/26 23:10
6F:推 leoloveivy: 没用过pytorch你是用gpu跑的吗 06/27 02:56
7F:→ leoloveivy: 这样可能要先run一个gpu的 06/27 02:56
8F:→ leoloveivy: 再计时不然可能会有context的问题 06/27 02:56
已补上gpu数据 ※ 编辑: robert780612 (211.72.69.157), 06/27/2018 07:53:41 ※ 编辑: robert780612 (211.72.69.157), 06/27/2018 07:54:38 ※ 编辑: robert780612 (211.72.69.157), 06/27/2018 07:55:22
9F:→ wrt: 这样比较不准唷 06/28 10:31
10F:→ wrt: 你应该把MAC一起算进去 06/28 10:31
11F:→ wrt: 毕竟你conv+stride和conv+pool运算量不一样 06/28 10:31
12F:→ wrt: 再来是用conv+stride就没办法享受到 06/28 10:31
13F:→ wrt: FFT或winograd等等的加速了 06/28 10:31
14F:→ wrt: 另外acc loss的问题都可以靠调整超参数或模型补回 06/28 10:31
15F:→ wrt: 不过如果没有使用进阶的FFT加速或是winograd 06/28 10:54
16F:→ wrt: 就大方使用conv+stride吧 06/28 10:54
17F:→ robert780612: 不是很懂你的意思 06/28 14:58
18F:→ robert780612: 因爲conv+stride运算量少,所以拿来取代conv+pool 06/28 15:00
19F:→ robert780612: 为什麽要在mac相同的情况下比较? 06/28 15:05
20F:→ yoyololicon: conv+stride为甚麽就不能有FFT加速?从DSP角度来看 06/28 22:49
21F:→ yoyololicon: stride只是在做downsampling而已 06/28 22:49
22F:→ wrt: 因为FFT就是在data分享下加速 07/01 18:07
23F:→ wrt: 如果有stride,那共享的data会变少,就影响加速 07/01 18:07
24F:推 sma1033: ""..................................ㄏ"" 07/02 09:08







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:iOS站内搜寻

TOP