示例#1
0
 def test_ml_attack_optimizer_nd_nd(self):
     mechanism = NoisyHist1()
     aopt = DPSniper(
         mechanism,
         LogisticRegressionFactory(
             in_dimensions=2, optimizer_factory=AdamOptimizerFactory()),
         DDConfig(n_train=10))
     attack = aopt.best_attack(np.array([5, 3]), np.array([4, 3]))
     res = attack.check(np.array([[5.1, 3.0], [3.2, 4.3], [0.1, 2.8]]))
     self.assertIsInstance(attack, MlAttack)
     self.assertEqual((3, ), res.shape)
示例#2
0
 def test_ml_attack_optimizer_nd_1d(self):
     mechanism = ReportNoisyMax1()
     aopt = DPSniper(
         mechanism,
         LogisticRegressionFactory(
             in_dimensions=1, optimizer_factory=AdamOptimizerFactory()),
         DDConfig(n_train=10))
     attack = aopt.best_attack(np.array([0.4, 2.8]), np.array([1.4, 1.8]))
     res = attack.check(np.array([0]))
     self.assertIsInstance(attack, MlAttack)
     self.assertEqual((1, ), res.shape)