def build(self, input_shape): channel_axis = self._channel_axis() input_shape = tensor_shape.TensorShape(input_shape) num_channels = input_shape[channel_axis].value if num_channels is None: raise ValueError("The channel dimension of the inputs to `GDN` " "must be defined.") self._input_rank = input_shape.ndims self.input_spec = base.InputSpec(ndim=input_shape.ndims, axes={channel_axis: num_channels}) self.beta = self._beta_parameterization(name="beta", shape=[num_channels], dtype=self.dtype, getter=self.add_variable, initializer=init_ops.Ones()) self.gamma = self._gamma_parameterization( name="gamma", shape=[num_channels, num_channels], dtype=self.dtype, getter=self.add_variable, initializer=init_ops.Identity(gain=self._gamma_init)) self.built = True
def test_Ones(self): tensor_shape = (4, 5) with self.cached_session(): self._runner(init_ops.Ones(), tensor_shape, target_mean=1., target_max=1.)
def test_Ones(self): shape = (4, 5) with self.cached_session(): for tensor_shape in [shape, tensor_shape_lib.TensorShape(shape)]: self._runner(init_ops.Ones(), tensor_shape, target_mean=1., target_max=1.)