Add Group Normalization

This commit is contained in:
zhaojichen 2020-04-16 01:56:12 -04:00
parent 898acc3201
commit 0b7de6968f
2 changed files with 3 additions and 3 deletions

View File

@ -346,7 +346,7 @@ class GroupNorm(Cell):
self.sqrt = P.Sqrt()
def construct(self, x):
batch, channel, height,width = self.shape(x)
batch, channel, height, width = self.shape(x)
x = self.reshape(x, (batch, self.num_groups, channel*height*width/self.num_groups))
mean = self.reduce_mean(x, 2)
var = self.reduce_sum(self.square(x - mean), 2) / (channel * height * width / self.num_groups - 1)