nvflare.app_common.filters package¶
Submodules¶
Module contents¶
- class ExcludeVars(exclude_vars: Optional[Union[List[str], str]] = None)[source]¶
Bases:
Filter
Exclude/Remove variables from Shareable.
- Parameters
exclude_vars (Union[List[str], str, None] , optional) – variables/layer names to be excluded.
Notes
- Based on different types of exclude_vars, this filter has different behavior:
if a list of variable/layer names, only specified variables will be excluded. if a string, it will be converted into a regular expression, only matched variables will be excluded. if not provided or other formats the Shareable remains unchanged.
- process(shareable: Shareable, fl_ctx: FLContext) Shareable [source]¶
Called by upper layer to remove variables in weights/weight_diff dictionary.
When the return code of shareable is not ReturnCode.OK, this function will not perform any process and returns the shareable back.
- Parameters
shareable (Shareable) – shareable must conform to DXO format.
fl_ctx (FLContext) – only used for logging.
- Returns
a shareable with excluded weights
- Return type
Shareable
- class PercentilePrivacy(percentile=10, gamma=0.01)[source]¶
Bases:
Filter
Implementation of “largest percentile to share” privacy preserving policy.
Shokri and Shmatikov, Privacy-preserving deep learning, CCS ‘15
- Parameters
percentile (int, optional) – Only abs diff greater than this percentile is updated. Allowed range 0..100. Defaults to 10.
gamma (float, optional) – The upper limit to truncate abs values of weight diff. Defaults to 0.01. Any weight diff with abs<gamma will become 0.
- process(shareable: Shareable, fl_ctx: FLContext) Shareable [source]¶
Compute the percentile on the abs delta_W.
Only share the params where absolute delta_W greater than the percentile value
- Parameters
shareable – information from client
fl_ctx – context provided by workflow
- Returns
a shareable containing the truncated weight diff
- Return type
Shareable
- class SVTPrivacy(fraction=0.1, epsilon=0.1, noise_var=0.1, gamma=1e-05, tau=1e-06)[source]¶
Bases:
Filter
Implementation of the standard Sparse Vector Technique (SVT) differential privacy algorithm.
lambda_rho = gamma * 2.0 / epsilon threshold = tau + np.random.laplace(scale=lambda_rho)
- Parameters
fraction (float, optional) – used to determine dataset threshold. Defaults to 0.1.
epsilon (float, optional) – Defaults to 0.1.
noise_var (float, optional) – additive noise. Defaults to 0.1.
gamma (float, optional) – Defaults to 1e-5.
tau (float, optional) – Defaults to 1e-6.