コード例 #1
0
ファイル: mechanism_zoo.py プロジェクト: pmcsh04/autodp
    def __init__(self, params, name='SubsampleGaussian'):
        Mechanism.__init__(self)
        self.name = name
        self.params = {
            'prob': params['prob'],
            'sigma': params['sigma'],
            'coeff': params['coeff']
        }
        # create such a mechanism as in previously
        subsample = transformer_zoo.AmplificationBySampling(
        )  # by default this is using poisson sampling
        mech = GaussianMechanism(sigma=params['sigma'])

        # Create subsampled Gaussian mechanism
        SubsampledGaussian_mech = subsample(mech,
                                            params['prob'],
                                            improved_bound_flag=True)

        # Now run this for niter iterations
        compose = transformer_zoo.Composition()
        mech = compose([SubsampledGaussian_mech], [params['coeff']])

        # Now we get it and let's extract the RDP function and assign it to the current mech being constructed
        rdp_total = mech.RenyiDP
        self.propagate_updates(rdp_total, type_of_update='RDP')
コード例 #2
0
    def __init__(self, prob, sigma, niter, PoissonSampling=True, name='NoisySGD'):
        Mechanism.__init__(self)
        self.name = name
        self.params = {'prob': prob, 'sigma': sigma, 'niter': niter,
                       'PoissonSampling': PoissonSampling}

        # create such a mechanism as in previously
        subsample = transformer_zoo.AmplificationBySampling(PoissonSampling=PoissonSampling)
        # by default this is using poisson sampling

        mech = ExactGaussianMechanism(sigma=sigma)
        prob = 0.01
        # Create subsampled Gaussian mechanism
        SubsampledGaussian_mech = subsample(mech, prob, improved_bound_flag=True)
        # for Gaussian mechanism the improved bound always applies

        # Now run this for niter iterations
        compose = transformer_zoo.Composition()
        mech = compose([SubsampledGaussian_mech], [niter])

        # Now we get it and let's extract the RDP function and assign it to the current mech being constructed
        rdp_total = mech.RenyiDP
        self.propagate_updates(rdp_total, type_of_update='RDP')