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/m.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燈, 水草

請輸入看板名稱,例如:e-shopping站內搜尋

TOP