shicai / MobileNet-Caffe

Caffe Implementation of Google's MobileNets (v1 and v2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

batchnorm layer variance exist negative numbers

KimmiShi opened this issue · comments

Hi, I found that the variance of batchnorm is negative, why a negative numbe is generated? Since the formula of variance is (X-mean)^2, it should always be positive?

reproduce:

>>> net=caffe.Net("mobilenet_v2_deploy.prototxt", "mobilenet_v2.caffemodel",caffe.TEST)
>>> data=net.params["conv2_1/dwise/bn"]
>>> data[1].data

In my machine, I got:

array([ 4.7596052e-02,  7.3651361e-01,  2.2111790e-02,  1.4638673e-01,
        8.1408697e-01,  4.1462550e+00, -9.9998997e-06,  7.0890152e-01,
        8.2080442e-01,  4.6168277e-01,  6.0621478e-02,  4.0049631e-02,
        7.5143494e-02, -9.9998997e-06,  7.3541865e-02,  1.2164615e+00,
        6.9410698e-03,  7.8000981e-01,  7.2208607e-01, -9.9998997e-06,
       -9.9998997e-06, -9.9920235e-06,  9.2403132e-01,  6.2930644e-01,
        6.8191504e-01,  2.1945512e+00, -4.9380765e-06,  9.1005945e-01,
        1.0808281e+00,  1.7053494e+00,  5.6995720e-01,  2.4290257e+00],
      dtype=float32)

I also fuond that and wonder why.