LISTENAI/linger

NormalizeConvBN2d问题

Opened this issue · 0 comments

(1 - self.bn.momentum) * self.bn.running_mean + self.bn.momentum * mean.detach())

(1 - self.bn.momentum) * self.bn.running_mean + self.bn.momentum * mean.detach())

是否应该是
self.bn.momentum * self.bn.running_mean + (1-self.bn.momentum) * mean.detach()),
参考

def Batchnorm_simple_for_train(x, gamma, beta, bn_param):
running_mean = bn_param['running_mean']
running_var = bn_param['running_var']
results = 0. #建立一个新的变量

x_mean = x.mean(axis=0) # Calculate mean of x
x_var = x.var(axis=0) # Calculate variance of x
x_normalized = (x-x_mean)/np.sqrt(x_var + eps)  # Normalization
results = gamma * x_normalized + beta

running_mean = momentum * running_mean + (1 - momentum) * x_mean
running_var = momentum * running_var + (1 - momentum) * x_var

# Record the new value
bn_param['running_mean'] = running_mean
bn_param['running_var'] = running_var

return results, bn_param