def _initialize_params(self, t):
xp = cuda.get_array_module(t)
self.mean_t = xp.mean(t, axis=(0, 2)) # calculate average for each channel
self.std_t = xp.sqrt(xp.var(t, axis=(0, 2))) # calculate stddev for each channel
g = 1 / self.std_t
b = -self.mean_t / self.std_t
# print("g <- {}, b <- {}".format(g.reshape((-1,)), b.reshape((-1,))))
with self.init_scope():
if self.nobias == False:
self.b = Parameter(b, b.shape)
g_shape = (self.out_channels, 1) + (1,) * len(self.ksize)
self.g = Parameter(g.reshape(g_shape), g_shape)
评论列表
文章目录