Skip to content

NormalizeConvBN2d问题 #2

@hyaihjq

Description

@hyaihjq

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions