pub struct DiffPrivacyEngine { /* private fields */ }Expand description
Differential privacy engine for adding calibrated noise.
Implementations§
Source§impl DiffPrivacyEngine
impl DiffPrivacyEngine
Sourcepub fn gaussian(
epsilon: f64,
delta: f64,
sensitivity: f64,
clipping_norm: f64,
) -> Result<Self, FederationError>
pub fn gaussian( epsilon: f64, delta: f64, sensitivity: f64, clipping_norm: f64, ) -> Result<Self, FederationError>
Create a new DP engine with Gaussian mechanism.
Default: epsilon=1.0, delta=1e-5 (strong privacy).
Sourcepub fn laplace(
epsilon: f64,
sensitivity: f64,
clipping_norm: f64,
) -> Result<Self, FederationError>
pub fn laplace( epsilon: f64, sensitivity: f64, clipping_norm: f64, ) -> Result<Self, FederationError>
Create a new DP engine with Laplace mechanism.
Sourcepub fn clip_gradients(&self, gradients: &mut [f64])
pub fn clip_gradients(&self, gradients: &mut [f64])
Clip a gradient vector to the configured L2 norm bound.
Sourcepub fn add_noise(&mut self, params: &mut [f64]) -> DiffPrivacyProof
pub fn add_noise(&mut self, params: &mut [f64]) -> DiffPrivacyProof
Add calibrated noise to a vector of parameters.
Clips gradients first, then adds noise per the configured mechanism.
Sourcepub fn add_noise_scalar(&mut self, value: &mut f64) -> f64
pub fn add_noise_scalar(&mut self, value: &mut f64) -> f64
Add noise to a single scalar value.
Auto Trait Implementations§
impl Freeze for DiffPrivacyEngine
impl RefUnwindSafe for DiffPrivacyEngine
impl Send for DiffPrivacyEngine
impl Sync for DiffPrivacyEngine
impl Unpin for DiffPrivacyEngine
impl UnsafeUnpin for DiffPrivacyEngine
impl UnwindSafe for DiffPrivacyEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more