pub struct DifferentialPrivacy { /* private fields */ }Expand description
Differential privacy for gradient protection
Implementations§
Source§impl DifferentialPrivacy
impl DifferentialPrivacy
Sourcepub fn new(
epsilon: f64,
delta: f64,
sensitivity: f64,
mechanism: DPMechanism,
) -> Self
pub fn new( epsilon: f64, delta: f64, sensitivity: f64, mechanism: DPMechanism, ) -> Self
Create a new differential privacy instance
Sourcepub fn add_gaussian_noise(
&mut self,
gradient: &mut [f32],
) -> Result<(), GradientError>
pub fn add_gaussian_noise( &mut self, gradient: &mut [f32], ) -> Result<(), GradientError>
Add Gaussian noise to gradient (for DP-SGD) Calibrated according to sensitivity and privacy parameters
Sourcepub fn add_laplacian_noise(
&mut self,
gradient: &mut [f32],
) -> Result<(), GradientError>
pub fn add_laplacian_noise( &mut self, gradient: &mut [f32], ) -> Result<(), GradientError>
Add Laplacian noise to gradient Calibrated according to L1 sensitivity and privacy parameters
Sourcepub fn apply_dp_sgd(
&mut self,
gradient: &mut [f32],
clip_norm: f32,
) -> Result<(), GradientError>
pub fn apply_dp_sgd( &mut self, gradient: &mut [f32], clip_norm: f32, ) -> Result<(), GradientError>
Apply DP-SGD (Differential Private Stochastic Gradient Descent) This clips gradients and adds noise
Sourcepub fn remaining_budget(&self) -> f64
pub fn remaining_budget(&self) -> f64
Get remaining privacy budget
Sourcepub fn is_budget_exhausted(&self) -> bool
pub fn is_budget_exhausted(&self) -> bool
Check if privacy budget is exhausted
Sourcepub fn get_privacy_params(&self) -> (f64, f64)
pub fn get_privacy_params(&self) -> (f64, f64)
Get privacy parameters
Auto Trait Implementations§
impl Freeze for DifferentialPrivacy
impl RefUnwindSafe for DifferentialPrivacy
impl Send for DifferentialPrivacy
impl Sync for DifferentialPrivacy
impl Unpin for DifferentialPrivacy
impl UnwindSafe for DifferentialPrivacy
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more