IAccountant

class opacus.accountants.accountant.IAccountant[source]
abstract get_epsilon(delta, *args, **kwargs)[source]

Return privacy budget (epsilon) expended so far.

Parameters:
  • delta (float) – target delta

  • *args – subclass-specific args

  • **kwargs – subclass-specific kwargs

Return type:

float

get_optimizer_hook_fn(sample_rate)[source]

Returns a callback function which can be used to attach to DPOptimizer :type sample_rate: float :param sample_rate: Expected samping rate used for accounting

Return type:

Callable[[DPOptimizer], None]

load_state_dict(state_dict)[source]

Validates the supplied state_dict and populates the current Privacy Accountant’s state dict.

Parameters:

state_dict (TypeVar(T_state_dict, bound= Mapping[str, Any])) – state_dict to load.

Raises:

ValueError if supplied state_dict is invalid and cannot be loaded.

abstract classmethod mechanism()[source]

Accounting mechanism name

Return type:

str

state_dict(destination=None)[source]

Retruns a dictionary containing the state of the accountant. :type destination: Optional[TypeVar(T_state_dict, bound= Mapping[str, Any])] :param destination: a mappable object to populate the current state_dict into.

If this arg is None, an OrderedDict is created and populated. Default: None

Return type:

TypeVar(T_state_dict, bound= Mapping[str, Any])

abstract step(*, noise_multiplier, sample_rate)[source]

Signal one optimization step

Parameters:
  • noise_multiplier (float) – Current noise multiplier

  • sample_rate (float) – Current sample rate