Пример #1
0
 def test_forward3(self):
     N, C = 20, 10
     x, gamma, beta, mean, var = get_params(N, C)
     cy = CF.fixed_batch_normalization(x, gamma, beta, mean, var)
     with dezero.test_mode():
         y = F.batch_nrom(x, gamma, beta, mean, var)
     self.assertTrue(array_allclose(y.data, cy.data))
 def test_forward1(self):
     N, C = 8, 1
     x, gamma, beta, mean, var = get_params(N, C)
     cy = CF.batch_normalization(x,
                                 gamma,
                                 beta,
                                 running_mean=mean,
                                 running_var=var)
     y = F.batch_nrom(x, gamma, beta, mean, var)
     self.assertTrue(array_allclose(y.data, cy.data))
Пример #3
0
 def __call__(self, x):
     if self.avg_mean.data is None:
         self._init_params(x)
     return F.batch_nrom(x, self.gamma, self.beta, self.avg_mean.data,
                         self.avg_var.data)
 def test_forward4(self):
     N, C, H, W = 20, 10, 5, 5
     x, gamma, beta, mean, var = get_params(N, C, H, W)
     cy = CF.batch_normalization(x, gamma, beta)
     y = F.batch_nrom(x, gamma, beta, mean, var)
     self.assertTrue(array_allclose(y.data, cy.data))
 def test_type1(self):
     N, C = 8, 3
     x, gamma, beta, mean, var = get_params(N, C)
     y = F.batch_nrom(x, gamma, beta, mean, var)
     self.assertTrue(y.data.dtype == np.float32)
 def test_backward6(self):
     params = 10, 20, 5, 5
     x, gamma, beta, mean, var = get_params(*params, dtype=np.float64)
     f = lambda beta: F.batch_nrom(x, gamma, beta, mean, var)
     self.assertTrue(gradient_check(f, beta))
 def test_backward3(self):
     N, C = 8, 3
     x, gamma, beta, mean, var = get_params(N, C, dtype=np.float64)
     f = lambda beta: F.batch_nrom(x, gamma, beta, mean, var)
     self.assertTrue(gradient_check(f, beta))