Example #1
0
 def end(self, session):
     orders = [1 + x / 10.0 for x in range(1, 100)] + list(range(12, 64))
     samples = session.run(self._samples)
     queries = session.run(self._queries)
     formatted_ledger = privacy_ledger.format_ledger(samples, queries)
     rdp = compute_rdp_from_ledger(formatted_ledger, orders)
     eps = get_privacy_spent(orders, rdp, target_delta=1e-5)[0]
     print('For delta=1e-5, the current epsilon is: %.2f' % eps)
Example #2
0
 def end(self, session):
     orders = [1 + x / 10.0 for x in range(1, 100)] + list(range(12, 64))
     samples = session.run(self._samples)
     queries = session.run(self._queries)
     formatted_ledger = privacy_ledger.format_ledger(samples, queries)
     rdp = compute_rdp_from_ledger(formatted_ledger, orders)
     eps = get_privacy_spent(orders, rdp, target_delta=1e-5)[0]
     sys.stdout.write(',%s' % eps)
     sys.stdout.flush()
Example #3
0
  def test_compute_rdp_from_ledger(self):
    orders = range(2, 33)
    q = 0.1
    n = 1000
    l2_norm_clip = 3.14159
    noise_stddev = 2.71828
    steps = 3

    query_entry = privacy_ledger.GaussianSumQueryEntry(
        l2_norm_clip, noise_stddev)
    ledger = [privacy_ledger.SampleEntry(n, q, [query_entry])] * steps

    z = noise_stddev / l2_norm_clip
    rdp = rdp_accountant.compute_rdp(q, z, steps, orders)
    rdp_from_ledger = rdp_accountant.compute_rdp_from_ledger(ledger, orders)
    self.assertSequenceAlmostEqual(rdp, rdp_from_ledger)
Example #4
0
    def _get_rdp_and_orders(self):
        orders = [1 + x / 10.0 for x in range(1, 100)] + list(range(12, 64))

        if self.ledger is None:
            steps = self.epochs * self.train_size // self.batch_size
            sampling_probability = self.batch_size / self.train_size
            rdp = compute_rdp(
                q=sampling_probability,
                noise_multiplier=self.noise_multiplier,
                steps=steps,
                orders=orders,
            )
        else:
            # calculate with ledger
            print("Formatted Ledger")
            formatted_ledger = self.ledger.get_formatted_ledger(get_session())
            rdp = compute_rdp_from_ledger(formatted_ledger, orders)
        return rdp, orders
Example #5
0
  def end(self, session):

    # Any RDP order (for order > 1) corresponds to one epsilon value. We
    # enumerate through a few orders and pick the one that gives lowest epsilon.
    # The variable orders may be extended for different use cases. Usually, the
    # search is set to be finer-grained for small orders and coarser-grained for
    # larger orders.
    orders = [1 + x / 10.0 for x in range(1, 100)] + list(range(12, 64))
    samples = session.run(self._samples)
    queries = session.run(self._queries)
    formatted_ledger = privacy_ledger.format_ledger(samples, queries)
    rdp = compute_rdp_from_ledger(formatted_ledger, orders)

    # It is recommended that delta is o(1/dataset_size). In the case of MNIST,
    # dataset_size is 60000, so we set delta to be 1e-5. For larger datasets,
    # delta should be set smaller.
    eps = get_privacy_spent(orders, rdp, target_delta=1e-5)[0]
    print('For delta=1e-5, the current epsilon is: %.2f' % eps)