vgg16 感受野計算


code:

 1 vgg_16 = [
 2     # 1
 3     [3, 1], [3, 1], [2, 2],
 4     # 2
 5     [3, 1],  [3, 1], [2, 2],
 6     # 3
 7     [3, 1], [3, 1], [3, 1], [2, 2],
 8     # 4
 9     [3, 1], [3, 1], [3, 1], [2, 2],
10     # 5
11     [3, 1], [3, 1], [3, 1], [2, 2],
12     # fc6, fake convolutional layer   
13     [7, 1]
14 ]
15 vgg16_layers = [
16     "3x3 conv 64", "3x3 conv 64", "pool1",
17     "3x3 conv 128", "3x3 conv 128", "pool2",
18     "3x3 conv 256", "3x3 conv 256", "3x3 conv 256", "pool3",
19     "3x3 conv 512", "3x3 conv 512", "3x3 conv 512", "pool4",
20     "3x3 conv 512", "3x3 conv 512", "3x3 conv 512", "pool5",
21     "7x7 fc"
22 ]
23 def cal_receptive_field(kspairs, layers=None):
24     # K: composed kernel, also the receptive field,累計的感受野
25     # S: composed stride,累計的步長
26     K, S = 1, 1
27     # H = 224
28     if not layers:
29         layers = range(len(kspairs))
30     for layer, kspair in zip(layers, kspairs):
31         k, s = kspair
32         K = (k-1) * S + K
33         S = S * s
34         # H = H//s
35         # iamge size {0}'.format(H)
36         
37         print('layer {:<15}: {} [{:3},{:2}]'.format(layer, kspair, K, S))
38         
39 cal_receptive_field(vgg_16, vgg16_layers)

參考:

Calculate Receptive Field for VGG16 | Zike's Blog


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM