def __init__()

in tensorflow_model_optimization/python/core/internal/tensor_encoding/stages/research/kashin.py [0:0]


  def __init__(self,
               num_iters=3,
               eta=0.9,
               delta=1.0,
               last_iter_clip=False,
               pad_extra_level_threshold=0.85):
    """Initializer for the `KashinHadamardEncodingStage`.

    Args:
      num_iters: An integer number of iterations to run to compute the
        representation. Cannot be a TensorFlow value.
      eta: A scalar parameter of the encoding algorithm. Determines the
        shrinkage of the clipping level in each iteration. Must be between 0 and
        1. Can be either a TensorFlow or a Python value.
      delta: A scalar parameter of the encoding algorithm. Determines the
        initial clipping level. Must be greater than 0. Can be either a
        TensorFlow or a Python value.
      last_iter_clip: A boolean, determining whether to apply clipping in last
        iteration of the encoding algorithm. If set to False, the encoded
        representation is always lossless. If set to True, the resulting
        representation can be lossy, although not necessarily. Cannot be a
        TensorFlow value.
      pad_extra_level_threshold: A scalar parameter determining the threshold,
        at which padding with zeros is to be expanded by an additional power of
        2. See class documentation for why this is needed. Cannot be a
        TensorFlow value.

    Raises:
      ValueError: The inputs do not satisfy the above constraints.
    """
    if tf.is_tensor(num_iters):
      raise ValueError('Parameter num_iters cannot be a TensorFlow value.')
    if not isinstance(num_iters, int) or num_iters <= 0:
      raise ValueError('Number of iterations must be a positive integer.'
                       'num_iters provided: %s' % num_iters)
    self._num_iters = num_iters

    if not tf.is_tensor(eta) and not 0.0 < eta < 1.0:
      raise ValueError('Parameter eta must be between 0 and 1. '
                       'Provided eta: %s' % eta)
    self._eta = eta

    if not tf.is_tensor(delta) and delta <= 0.0:
      raise ValueError('Parameter delta must be greater than 0. '
                       'Provided delta: %s' % delta)
    self._delta = delta

    if tf.is_tensor(last_iter_clip):
      raise ValueError('Parameter last_iter_clip cannot be a TensorFlow value.')
    if not isinstance(last_iter_clip, bool):
      raise ValueError('Parameter last_iter_clip must be a bool.')
    self._last_iter_clip = last_iter_clip

    if tf.is_tensor(pad_extra_level_threshold):
      raise ValueError(
          'Parameter pad_extra_level_threshold cannot be a TensorFlow value.')
    self._pad_extra_level_threshold = pad_extra_level_threshold