jax_privacy.clipping.BoundedSensitivityCallable#

class jax_privacy.clipping.BoundedSensitivityCallable(bounded_sensitivity_fun, l2_norm_bound, has_aux)[source]#

Bases: object

Callable with a sensitivity property.

If has_aux is False, the sensitivity guarantee holds for the entire output which may be an arbitrary PyTree of JAX Arrays. If has_aux is True, the output of the function is a pair (value, aux) and the sensitivity guarantee only holds for the value PyTree. The aux PyTree is returned on a per-example basis (i.e., as a PyTree of arrays having a batch axis). The caller should handle the aux output with care w.r.t. DP guarantees, should they be needed.

Methods

__init__

sensitivity

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 fun passed to clipped_fun or clipped_grad.

  • is_padding_example (Array | None) – An optional 1-D boolean jax.Array of 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 to NaN. 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_fun or clipped_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.