Negative value of running_var in batchnorm layer

I try to train a YOLO object detector by pytorch and implement the model on FPGA. And When I check the value of running_var in batchnorm layer, there were some negative values.
I thought running_var was supposed to be positive. Did I miss something? Or Could anyone tell me the formula to calculate the batchnorm output with variables weight, bias, running_var, running_mean?

Thanks,
Min

Hi, I came across this problem too. This problem is caused by the 32/64 bit compiler problem. The metadata of Yolo’s weight file is composed of 3 int and 1 size_t, unfortunately the size_t depends on your compiler and machine. For the official weight file, size_t==32bit, for your own weight file, it varies.

In brief, you may want to escape the first 5 int32 instead of 4 int32.

e.g.

you may try count=5 in this case.