RuntimeError: the derivative for ‘running_mean’ is not implemented

when I use x = nf.batch_norm(x, running_mean=self.bn1_mean, running_var=self.bn1_var, weight=None, bias=None, training=False, momentum=0.1, eps=1e-05) in my net, I defined the self.bn1_mean and self.bn1_var, but when running train, there com out RuntimeError: the derivative for ‘running_mean’ is not implemented, why ??

Hi @sfancc,

This is related to this GitHub issue.

running_mean and running_var are only initialized by those value (bn1_mean and bn1_var) but are not trainable parameters.

import torch.nn.functional as nf