64 def forward(self, x):
65 """
66 0, 1, 2, 3 -> (B, H, W, C) in TensorFlow
67 0, 1, 2, 3 -> (B, C, H, W) in PyTorch
68 TensorFlow code
69 nu2 = tf.reduce_mean(tf.square(x), axis=[1, 2], keepdims=True)
70 x = x * tf.rsqrt(nu2 + tf.abs(eps))
71 # This Code include TLU function max(y, tau)
72 return tf.maximum(gamma * x + beta, tau)
73 """
74
75 nu2 = x.pow(2).mean(dim=[2, 3], keepdim=True)
76
77
78 x = x * torch.rsqrt(nu2 + self.eps.abs())
79
80
81 x = self.weight.view(1, self.num_features, 1, 1) * x + self.bias.view(1, self.num_features, 1, 1)
82
83 return x
84
85