class_docstr: `DPQuery` for tree aggregation queries with adaptive clipping.
  
  The implementation is based on tree aggregation noise for cumulative sum in
  "Practical and Private (Deep) Learning without Sampling or Shuffling"
  (https://arxiv.org/abs/2103.00039) and quantile-based adaptive clipping in
  "Differentially Private Learning with Adaptive Clipping"
  (https://arxiv.org/abs/1905.03871).
  
  The quantile value will be continuously estimated, but the clip norm is only
  updated when `reset_state` is called, and the tree state will be reset. This
  will force the clip norm (and corresponding stddev) in a tree unchanged.
class_docstr_tok: ["`","DPQuery","`","for","tree","aggregation","queries","with","adaptive","clipping",".","The","implementation","is","based","on","tree","aggregation","noise","for","cumulative","sum","in","''","Practical","and","Private","(","Deep",")","Learning","without","Sampling","or","Shuffling","''","(","https",":","\/\/arxiv.org\/abs\/2103.00039",")","and","quantile-based","adaptive","clipping","in","''","Differentially","Private","Learning","with","Adaptive","Clipping","''","(","https",":","\/\/arxiv.org\/abs\/1905.03871",")",".","The","quantile","value","will","be","continuously","estimated",",","but","the","clip","norm","is","only","updated","when","`","reset_state","`","is","called",",","and","the","tree","state","will","be","reset",".","This","will","force","the","clip","norm","(","and","corresponding","stddev",")","in","a","tree","unchanged","."]
docstr: Initializes the `QAdaClipTreeResSumQuery`.
  
  Args:
    initial_l2_norm_clip: The initial value of clipping norm.
    noise_multiplier: The stddev of the noise added to the output will be this
      times the current value of the clipping norm.
    record_specs: A nested structure of `tf.TensorSpec`s specifying structure
      and shapes of records.
    target_unclipped_quantile: The desired quantile of updates which should be
      unclipped. I.e., a value of 0.8 means a value of l2_norm_clip should be
      found for which approximately 20% of updates are clipped each round.
      Andrew et al. recommends that this be set to 0.5 to clip to the median.
    learning_rate: The learning rate for the clipping norm adaptation. With
      geometric updating, a rate of r means that the clipping norm will change
      by a maximum factor of exp(r) at each round. This maximum is attained
      when |actual_unclipped_fraction - target_unclipped_quantile| is 1.0.
      Andrew et al. recommends that this be set to 0.2 for geometric updating.
    clipped_count_stddev: The stddev of the noise added to the clipped_count.
      Andrew et al. recommends that this be set to `expected_num_records / 20`
      for reasonably fast adaptation and high privacy.
    expected_num_records: The expected number of records per round, used to
      estimate the clipped count quantile.
    geometric_update: If `True`, use geometric updating of clip (recommended).
    noise_seed: Integer seed for the Gaussian noise generator of
      `TreeResidualSumQuery`. If `None`, a nondeterministic seed based on
      system time will be generated.
docstr_tok: ["Initializes","the","`","QAdaClipTreeResSumQuery","`",".","Args",":","initial_l2_norm_clip",":","The","initial","value","of","clipping","norm",".","noise_multiplier",":","The","stddev","of","the","noise","added","to","the","output","will","be","this","times","the","current","value","of","the","clipping","norm",".","record_specs",":","A","nested","structure","of","`","tf.TensorSpec","`","s","specifying","structure","and","shapes","of","records",".","target_unclipped_quantile",":","The","desired","quantile","of","updates","which","should","be","unclipped",".","I.e.",",","a","value","of","0.8","means","a","value","of","l2_norm_clip","should","be","found","for","which","approximately","20","%","of","updates","are","clipped","each","round",".","Andrew","et","al",".","recommends","that","this","be","set","to","0.5","to","clip","to","the","median",".","learning_rate",":","The","learning","rate","for","the","clipping","norm","adaptation",".","With","geometric","updating",",","a","rate","of","r","means","that","the","clipping","norm","will","change","by","a","maximum","factor","of","exp","(","r",")","at","each","round",".","This","maximum","is","attained","when","|actual_unclipped_fraction","-","target_unclipped_quantile|","is","1.0",".","Andrew","et","al",".","recommends","that","this","be","set","to","0.2","for","geometric","updating",".","clipped_count_stddev",":","The","stddev","of","the","noise","added","to","the","clipped_count",".","Andrew","et","al",".","recommends","that","this","be","set","to","`","expected_num_records","\/","20","`","for","reasonably","fast","adaptation","and","high","privacy",".","expected_num_records",":","The","expected","number","of","records","per","round",",","used","to","estimate","the","clipped","count","quantile",".","geometric_update",":","If","`","True","`",",","use","geometric","updating","of","clip","(","recommended",")",".","noise_seed",":","Integer","seed","for","the","Gaussian","noise","generator","of","`","TreeResidualSumQuery","`",".","If","`","None","`",",","a","nondeterministic","seed","based","on","system","time","will","be","generated","."]
code: def __init__(
      self,
      initial_l2_norm_clip,
      noise_multiplier,
      record_specs,
      target_unclipped_quantile,
      learning_rate,
      clipped_count_stddev,
      expected_num_records,
      geometric_update=True,
      noise_seed=None,
  ):
      """Initializes the `QAdaClipTreeResSumQuery`.
  
      Args:
        initial_l2_norm_clip: The initial value of clipping norm.
        noise_multiplier: The stddev of the noise added to the output will be this
          times the current value of the clipping norm.
        record_specs: A nested structure of `tf.TensorSpec`s specifying structure
          and shapes of records.
        target_unclipped_quantile: The desired quantile of updates which should be
          unclipped. I.e., a value of 0.8 means a value of l2_norm_clip should be
          found for which approximately 20% of updates are clipped each round.
          Andrew et al. recommends that this be set to 0.5 to clip to the median.
        learning_rate: The learning rate for the clipping norm adaptation. With
          geometric updating, a rate of r means that the clipping norm will change
          by a maximum factor of exp(r) at each round. This maximum is attained
          when |actual_unclipped_fraction - target_unclipped_quantile| is 1.0.
          Andrew et al. recommends that this be set to 0.2 for geometric updating.
        clipped_count_stddev: The stddev of the noise added to the clipped_count.
          Andrew et al. recommends that this be set to `expected_num_records / 20`
          for reasonably fast adaptation and high privacy.
        expected_num_records: The expected number of records per round, used to
          estimate the clipped count quantile.
        geometric_update: If `True`, use geometric updating of clip (recommended).
        noise_seed: Integer seed for the Gaussian noise generator of
          `TreeResidualSumQuery`. If `None`, a nondeterministic seed based on
          system time will be generated.
      """
      self._noise_multiplier = noise_multiplier
  
      self._quantile_estimator_query = (
          quantile_estimator_query.TreeQuantileEstimatorQuery(
              initial_l2_norm_clip,
              target_unclipped_quantile,
              learning_rate,
              clipped_count_stddev,
              expected_num_records,
              geometric_update,
          )
      )
  
      self._sum_query = tree_aggregation_query.TreeResidualSumQuery.build_l2_gaussian_query(
          initial_l2_norm_clip,
          noise_multiplier,
          record_specs,
          noise_seed=noise_seed,
          use_efficient=True,
      )
  
      assert isinstance(self._sum_query, dp_query.SumAggregationDPQuery)
      assert isinstance(
          self._quantile_estimator_query, dp_query.SumAggregationDPQuery
      )
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_tree_query.py
imports: import collections
  import dp_accounting
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import dp_query
  from tensorflow_privacy.privacy.dp_query import quantile_estimator_query
  from tensorflow_privacy.privacy.dp_query import tree_aggregation_query
label_desc: Use image node_id 1 to create a new QAdaClipTreeResSumQuery object from inherited base classes: dp_query with example: obj = QAdaClipTreeResSumQuery(initial_l2_norm_clip, noise_multiplier, record_specs, target_unclipped_quantile, learning_rate, clipped_count_stddev, expected_num_records, geometric_update, noise_seed)