caffe的batchnorm层解析

batch norm层

batch norm有三组参数

打印参数的流程为:

>>> import sys
>>> sys.path.insert(0,'./python')
>>> import caffe
>>> net = caffe.Net('./examples/mnist/lenet_train_test.prototxt','./examples/mnist/lenet_iter_10000.caffemodel',caffe.TEST)

>>> net.params['S_BatchNorm1'][0].data.shape
(48,)
>>> net.params['S_BatchNorm1'][0].data
array([ 819.11981201,  829.95129395,  794.78631592,  827.35858154,
        850.00958252,  816.28717041,  827.91516113,  799.91137695,
        828.44311523,  826.17230225,  830.20861816,  820.72338867,
        874.72167969,  790.52697754,  830.56390381,  809.5446167 ,
        826.6975708 ,  826.20227051,  862.22235107,  834.30084229,
        838.55450439,  823.67590332,  849.53387451,  826.62652588,
        818.92474365,  853.89550781,  815.99163818,  838.94012451,
        825.40240479,  838.93945312,  828.55383301,  759.22088623,
        824.87506104,  829.83129883,  825.13092041,  918.137146  ,
        887.98748779,  828.19226074,  843.36413574,  832.51928711,
        818.15814209,  815.32025146,  852.34960938,  848.97436523,
        810.09857178,  793.54125977,  834.05938721,  785.15637207], dtype=float32)
其实是mean的和
>>> net.params['S_BatchNorm1'][1].data
array([ 29.82979965,  17.90246964,  28.48996925,  16.73427582,
        52.08065796,  23.63191414,  42.49412155,  32.62079239,
        22.55072594,  12.61812878,   8.74132729,  43.2579155 ,
        39.9254837 ,   6.50472021,  16.77551651,  20.26323318,
         7.65308332,  26.38513565,  10.02313232,  46.96594238,
        31.32673836,  15.16614246,  32.49311829,  17.75225258,
        13.66149616,  32.06713104,  30.29079819,  12.70900154,
         9.03455734,  26.99464035,  37.29315948,  12.5563097 ,
        43.37051392,  56.11575699,  31.56432915,  24.75470352,
        17.89116859,   5.47338533,  45.2383728 ,  24.48766518,
         7.36466312,  13.79270363,  19.93126678,  25.57545853,
        42.41948318,  28.65270233,  17.43808174,  14.86530399], dtype=float32)
>>> net.params['S_BatchNorm1'][2].data.shape
(1,)
>>> net.params['S_BatchNorm1'][2].data
array([ 999.98236084], dtype=float32)
次数
blobs[0]/blobs[2]才是mean
>>>
>>> net.params['S_BatchNorm1'][3].data.shape
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: Index out of range

[1]这个博客讲解的很详细 https://blog.csdn.net/lanran2/article/details/56278072 

猜你喜欢

转载自blog.csdn.net/andeyeluguo/article/details/80094000