def __init__(self, filters, kernel_size, strides=None, padding='VALID', dimension_numbers=('NHWC', 'HWIO', 'NHWC'), kernel_initializer=None, bias_initializer=init.RandomNormalInitializer(1e-6)): super(Conv, self).__init__() self._filters = filters self._kernel_size = kernel_size self._padding = padding self._dimension_numbers = dimension_numbers self._lhs_spec, self._rhs_spec, self._out_spec = dimension_numbers self._one = (1,) * len(kernel_size) self._strides = strides or self._one self._bias_initializer = bias_initializer rhs_spec = self._rhs_spec self._kernel_initializer = kernel_initializer if kernel_initializer is None: self._kernel_initializer = init.GlorotNormalInitializer( rhs_spec.index('O'), rhs_spec.index('I'))
def test_glorot_normal(self): initializer = initializers.GlorotNormalInitializer() input_shape = (29, 5, 7, 20) init_value = initializer(input_shape, random.get_prng(0)) self.assertEqual(tuple(init_value.shape), input_shape)