예제 #1
0
  def __init__(self,
               init_stamp_token,
               epsilon,
               num_quantiles,
               name=None,
               container=None):
    """Creates a QuantileAccumulator object.

    Args:
      init_stamp_token: The initial value for the stamp token.
      epsilon: Error bound on the quantile computation.
      num_quantiles: Number of quantiles to produce from the final summary.
      name: the name to save the accumulator under.
      container: An optional `string`. Defaults to `""`
    """
    self._epsilon = epsilon

    name = _PATTERN.sub("", name)
    with ops.name_scope(name, "QuantileAccumulator") as name:
      self._quantile_accumulator_handle = (
          gen_quantile_ops.quantile_stream_resource_handle_op(
              container=container, shared_name=name, name=name))
      self._create_op = gen_quantile_ops.create_quantile_accumulator(
          self._quantile_accumulator_handle,
          init_stamp_token,
          epsilon=epsilon,
          num_quantiles=num_quantiles)
      is_initialized_op = gen_quantile_ops.quantile_accumulator_is_initialized(
          self._quantile_accumulator_handle)
    resources.register_resource(self._quantile_accumulator_handle,
                                self._create_op, is_initialized_op)
    self._make_savable(name)
예제 #2
0
    def __init__(self,
                 init_stamp_token,
                 epsilon,
                 num_quantiles,
                 max_elements=None,
                 name=None,
                 container=None):
        """Creates a QuantileAccumulator object.

    Args:
      init_stamp_token: The initial value for the stamp token.
      epsilon: Error bound on the quantile computation.
      num_quantiles: Number of quantiles to produce from the final summary.
      max_elements: Maximum number of elements added to the accumulator.
      name: the name to save the accumulator under.
      container: An optional `string`. Defaults to `""`
    """
        self._epsilon = epsilon

        name = _PATTERN.sub("", name)
        with ops.name_scope(name, "QuantileAccumulator") as name:
            self._quantile_accumulator_handle = (
                gen_quantile_ops.quantile_stream_resource_handle_op(
                    container=container, shared_name=name, name=name))
            self._create_op = gen_quantile_ops.create_quantile_accumulator(
                self._quantile_accumulator_handle,
                init_stamp_token,
                epsilon=epsilon,
                max_elements=max_elements,
                num_quantiles=num_quantiles)
            is_initialized_op = gen_quantile_ops.quantile_accumulator_is_initialized(
                self._quantile_accumulator_handle)
        resources.register_resource(self._quantile_accumulator_handle,
                                    self._create_op, is_initialized_op)
        self._make_savable(name)
예제 #3
0
  def __init__(self,
               init_stamp_token,
               epsilon,
               num_quantiles,
               max_elements=None,
               name=None,
               container=None,
               generate_quantiles=False):
    """Creates a QuantileAccumulator object.

    Args:
      init_stamp_token: The initial value for the stamp token.
      epsilon: Error bound on the quantile computation.
      num_quantiles: Number of quantiles to produce from the final summary.
      max_elements: Maximum number of elements added to the accumulator.
      name: the name to save the accumulator under.
      container: An optional `string`. Defaults to `""`
      generate_quantiles: Generate quantiles instead of approximate boundaries.
        If true, exactly `num_quantiles` will be produced in the final summary.
    """
    self._epsilon = epsilon
    self._generate_quantiles = generate_quantiles

    name = _PATTERN.sub("", name)
    with ops.name_scope(name, "QuantileAccumulator") as name:
      self._quantile_accumulator_handle = (
          gen_quantile_ops.quantile_stream_resource_handle_op(
              container=container, shared_name=name, name=name))
      self._create_op = gen_quantile_ops.create_quantile_accumulator(
          self._quantile_accumulator_handle,
          init_stamp_token,
          epsilon=epsilon,
          max_elements=max_elements,
          num_quantiles=num_quantiles,
          generate_quantiles=generate_quantiles)
      is_initialized_op = gen_quantile_ops.quantile_accumulator_is_initialized(
          self._quantile_accumulator_handle)
    resources.register_resource(self._quantile_accumulator_handle,
                                self._create_op, is_initialized_op)
    self._make_savable(name)
 def _create_resource(self):
   return gen_quantile_ops.quantile_stream_resource_handle_op(
       container=self._container, shared_name=self._name, name=self._name)