예제 #1
0
 def test_positive_parameterizer(self):
     shape = (1, 2, 3, 4)
     var = self._test_parameterizer(
         parameterizers.NonnegativeParameterizer(minimum=.1),
         tf.initializers.random_uniform(), shape)
     self.assertEqual(var.shape, shape)
     self.assertTrue(np.all(var >= .1))
예제 #2
0
from __future__ import print_function

# Dependency imports

from tensorflow.python.eager import context
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.layers import base
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn

from tensorflow_compression.python.layers import parameterizers

_default_beta_param = parameterizers.NonnegativeParameterizer(minimum=1e-6)
_default_gamma_param = parameterizers.NonnegativeParameterizer()


class GDN(base.Layer):
    """Generalized divisive normalization layer.

  Based on the papers:

  > "Density modeling of images using a generalized normalization
  > transformation"<br />
  > J. Ballé, V. Laparra, E.P. Simoncelli<br />
  > https://arxiv.org/abs/1511.06281

  > "End-to-end optimized image compression"<br />
  > J. Ballé, V. Laparra, E.P. Simoncelli<br />