Ejemplo n.º 1
0
    def test_Identity(self):
        with self.cached_session():
            tensor_shape = (3, 4, 5)
            with self.assertRaises(ValueError):
                self._runner(init_ops.Identity(),
                             tensor_shape,
                             target_mean=1. / tensor_shape[0],
                             target_max=1.)

            tensor_shape = (3, 3)
            self._runner(init_ops.Identity(),
                         tensor_shape,
                         target_mean=1. / tensor_shape[0],
                         target_max=1.)
Ejemplo n.º 2
0
    def test_Identity(self):
        with self.cached_session():
            shape = (3, 4, 5)
            for tensor_shape in [shape, tensor_shape_lib.TensorShape(shape)]:
                with self.assertRaises(ValueError):
                    self._runner(init_ops.Identity(),
                                 tensor_shape,
                                 target_mean=1. / int(tensor_shape[0]),
                                 target_max=1.)

            shape = (3, 3)
            for tensor_shape in [shape, tensor_shape_lib.TensorShape(shape)]:
                self._runner(init_ops.Identity(),
                             tensor_shape,
                             target_mean=1. / int(tensor_shape[0]),
                             target_max=1.)
Ejemplo n.º 3
0
    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