Exemplo n.º 1
0
 def test_init(self, BatchNormLayer, init_unique):
     input_shape = (2, 3, 4)
     # default: normalize over all but second axis
     beta = BatchNormLayer(input_shape, beta=init_unique).beta
     assert np.allclose(beta.get_value(), init_unique((3, )))
     # normalize over first axis only
     beta = BatchNormLayer(input_shape, beta=init_unique, axes=0).beta
     assert np.allclose(beta.get_value(), init_unique((3, 4)))
     # normalize over second and third axis
     beta = BatchNormLayer(input_shape, beta=init_unique, axes=(1, 2)).beta
     assert np.allclose(beta.get_value(), init_unique((2, )))
Exemplo n.º 2
0
 def test_init(self, BatchNormLayer, init_unique):
     input_shape = (2, 3, 4)
     # default: normalize over all but second axis
     beta = BatchNormLayer(input_shape, beta=init_unique).beta
     assert np.allclose(beta.get_value(), init_unique((3,)))
     # normalize over first axis only
     beta = BatchNormLayer(input_shape, beta=init_unique, axes=0).beta
     assert np.allclose(beta.get_value(), init_unique((3, 4)))
     # normalize over second and third axis
     beta = BatchNormLayer(input_shape, beta=init_unique, axes=(1, 2)).beta
     assert np.allclose(beta.get_value(), init_unique((2,)))
Exemplo n.º 3
0
 def test_init(self, BatchNormLayer, init_unique):
     input_shape = (2, 3, 4)
     # default: normalize over all but second axis
     beta = BatchNormLayer(input_shape, beta=init_unique).beta
     assert np.allclose(beta.get_value(), init_unique((3, )))
     # normalize over first axis only
     beta = BatchNormLayer(input_shape, beta=init_unique, axes=0).beta
     assert np.allclose(beta.get_value(), init_unique((3, 4)))
     # normalize over second and third axis
     try:
         beta = BatchNormLayer(input_shape, beta=init_unique,
                               axes=(1, 2)).beta
         assert np.allclose(beta.get_value(), init_unique((2, )))
     except ValueError as exc:
         assert "BatchNormDNNLayer only supports" in exc.args[0]
Exemplo n.º 4
0
 def test_init(self, BatchNormLayer, init_unique):
     input_shape = (2, 3, 4)
     # default: normalize over all but second axis
     beta = BatchNormLayer(input_shape, beta=init_unique).beta
     assert np.allclose(beta.get_value(), init_unique((3,)))
     # normalize over first axis only
     beta = BatchNormLayer(input_shape, beta=init_unique, axes=0).beta
     assert np.allclose(beta.get_value(), init_unique((3, 4)))
     # normalize over second and third axis
     try:
         beta = BatchNormLayer(
                 input_shape, beta=init_unique, axes=(1, 2)).beta
         assert np.allclose(beta.get_value(), init_unique((2,)))
     except ValueError as exc:
         assert "BatchNormDNNLayer only supports" in exc.args[0]