ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tf_privacy.GaussianSumQuery

Implements DPQuery interface for Gaussian sum queries.

Inherits From: SumAggregationDPQuery, DPQuery

Clips records to bound the L2 norm, then adds Gaussian noise to the sum.

l2_norm_clip The clipping norm to apply to the global norm of each record.
stddev The stddev of the noise added to the sum.

Methods

accumulate_preprocessed_record

View source

Implements tensorflow_privacy.DPQuery.accumulate_preprocessed_record.

accumulate_record

View source

Accumulates a single record into the sample state.

This is a helper method that simply delegates to preprocess_record and accumulate_preprocessed_record for the common case when both of those functions run on a single device. Typically this will be a simple sum.

Args
params The parameters for the sample. In standard DP-SGD training, the clipping norm for the sample's microbatch gradients (i.e., a maximum norm magnitude to which each gradient is clipped)
sample_state The current sample state. In standard DP-SGD training, the accumulated sum of previous clipped microbatch gradients.
record The record to accumulate. In standard DP-SGD training, the gradient computed for the examples in one microbatch, which may be the gradient for just one example (for size 1 microbatches).

Returns
The updated sample state. In standard DP-SGD training, the set of previous microbatch gradients with the addition of the record argument.

derive_metrics

View source

Derives metric information from the current global state.

Any metrics returned should be derived only from privatized quantities.

Args
global_state The global state from which to derive metrics.

Returns
A collections.OrderedDict mapping string metric names to tensor values.

derive_sample_params

View source

Implements tensorflow_privacy.DPQuery.derive_sample_params.

get_noised_result

View source

Implements tensorflow_privacy.DPQuery.get_noised_result.

initial_global_state

View source

Implements tensorflow_privacy.DPQuery.initial_global_state.

initial_sample_state

View source

Implements tensorflow_privacy.DPQuery.initial_sample_state.

make_global_state

View source

Creates a global state from the given parameters.

merge_sample_states

View source

Implements tensorflow_privacy.DPQuery.merge_sample_states.

preprocess_record

View source

Implements tensorflow_privacy.DPQuery.preprocess_record.

preprocess_record_impl

View source

Clips the l2 norm, returning the clipped record and the l2 norm.

Args
params The parameters for the sample.
record The record to be processed.

Returns
A tuple (preprocessed_records, l2_norm) where preprocessed_records is the structure of preprocessed tensors, and l2_norm is the total l2 norm before clipping.