I’m trying to get the correct function of batchnorm2d.
Suppose my model is the following

class Net(nn.Module):
def init(self):
super(Net, self).init()
self.conv1 = nn.Conv2d(1, 32, 5,padding=2)
self.pool = nn.MaxPool2d(2, 2)
self.bn1 = torch.nn.BatchNorm2d(32)
self.fc1 = nn.Linear(321414, 10)
def forward(self, x):
    x = self.bn1(self.pool(self.conv1(x))) 
    x = F.relu(x)
    x = x.view(-1, 32 * 14 * 14)
    x = self.fc1(x)
    return x

net=Net()
tem1 = net.pool(net.conv1(x))

Could you please tell me what is the equivalent of below equation?

bn = net.bn1(tem1)

The most closed equation I can have is

net.bn1.weight.view([32,1,1])*((tem1 - net.bn1.running_mean.view([32,1,1]))/((net.bn1.running_var.view([32,1,1]) + net.bn1.eps).sqrt())) + net.bn1.bias.view([32,1,1])

But still it has a slight difference with net.bn1(tem1)
Many thanks.