jax_privacy.noise_addition.matrix_factorization_privatizer#
- jax_privacy.noise_addition.matrix_factorization_privatizer(noising_matrix, *, stddev, prng_key=None, dtype=None, intermediate_strategy=ShardingStrategies.DEFAULT)[source]#
Creates a gradient privatizer that adds correlated noise to gradients.
This implementation is described in Section 4.4 of Correlated Noise Mechanisms for Differentially Private Learning. A different implementation will be used depending on whether the
noising_matrixis ajax.Arrayor aStreamingMatrix. The dtype of the noise generated by this privatizer will be determined by thenoising_matrixand the input gradients according to standard jax type promotion rules. The output of the privatize transformation will always match the input dtype.For naming of these parameters, see the matrix_factorization README.
- Parameters:
noising_matrix (
Union[Array,ndarray,bool,number,bool,int,float,complex,StreamingMatrix]) – A matrix used to generate correlated noise. Noise samples will be distributed according to a multivariate Gaussian with covariance matrixnoising_matrix @ noising_matrix.T.stddev (
float) – Standard deviation to use for the noise of this privatizer.prng_key (
Array|int|None) – An optional PRNGKey array representing the source of randomness.dtype (
Union[str,type[Any],dtype,SupportsDType,None]) – The dtype to use for intermediate noise. If specified, noise will be generated with this dtype, added to the input gradient according to normal jax type promotion rules, and then cast back to the gradient dtype.intermediate_strategy (
ShardingStrategies) – Strategy to use for generating intermediate noise.
- Return type:
- Returns:
An
optax.GradientTransformationwhich adds samples from Gaussian correlated bynoising_matrix(i.e., samples from a Gaussian with covariancenoising_matrix @ noising_matrix.T), keyed byprng_key, to its stream of gradients.