jax_privacy.clipping.BoundedSensitivityCallable#
- class jax_privacy.clipping.BoundedSensitivityCallable(bounded_sensitivity_fun, l2_norm_bound, has_aux)[source]#
Bases:
objectCallable with a sensitivity property.
If
has_auxisFalse, the sensitivity guarantee holds for the entire output which may be an arbitrary PyTree of JAX Arrays. Ifhas_auxisTrue, the output of the function is a pair(value, aux)and the sensitivity guarantee only holds for thevaluePyTree. TheauxPyTree is returned on a per-example basis (i.e., as a PyTree of arrays having a batch axis). The caller should handle theauxoutput with care w.r.t. DP guarantees, should they be needed.Methods
__init__Returns the L2 sensitivity of the Callable.
Attributes
-
bounded_sensitivity_fun:
Callable[...,Any]#
-
l2_norm_bound:
float#
-
has_aux:
bool#
- __call__(*args, is_padding_example=None, **kwargs)[source]#
Calls the underlying clipped function.
- Parameters:
*args – The same positional arguments as the original
funpassed toclipped_funorclipped_grad.is_padding_example (
Array|None) – An optional 1-D booleanjax.Arrayof shape(batch_size,)indicating which examples in the batch are synthetic padding (True) vs. real data (False). Padding examples are zeroed out after clipping but before summation, so they contribute exactly zero to the aggregated output and do not affect the formal sensitivity guarantee. Floating-point leaves of per-example auxiliary outputs and norms at padding positions are set toNaN. When omitted, all examples are treated as real. For a full guide, see Using is_padding_example.**kwargs – Forwards all keyword arguments to the underlying function.
- Returns:
The clipped and aggregated output. See the docstring of the factory function (
clipped_funorclipped_grad) that created this instance for the exact return signature.
- sensitivity(neighboring_relation=NeighboringRelation.REPLACE_SPECIAL)[source]#
Returns the L2 sensitivity of the Callable.
The L2 sensitivity is defined with respect to the given neighboring relation and the unit of privacy implied by the function that created this instance.
- Parameters:
neighboring_relation (
NeighboringRelation) – The neighboring relation to consider.- Returns:
The L2 sensitivity of the Callable.
-
bounded_sensitivity_fun: