Пример #1
0
    def Run(self, W, x, eps, seed):
        prng = np.random.RandomState(seed)
        M = selection.H2(x.shape).select()
        y  = measurement.Laplace(M, eps).measure(x, prng)
        x_hat = inference.LeastSquares().infer(M, y)

        return x_hat
Пример #2
0
    def test_H2(self):
        op_H2_1D = selection.H2(self.domain_shape_1D)
        queries = op_H2_1D.select()
        if sparse.issparse(queries):
            queries = queries.todense()

        self.assertEqual(queries.shape[0], 31)
        self.assertEqual(queries.shape[1], 16)
Пример #3
0
    def Run(self, W, x, eps, seed):
        x = x.flatten()
        prng = np.random.RandomState(seed)
        M = selection.H2(self.domain_shape).select()

        if not isinstance(M, np.ndarray):
            M = M.toarray()

        y  = measurement.Laplace(M, eps).measure(x, prng)
        x_hat = inference.LeastSquares().infer(M, y)

        return x_hat
Пример #4
0
    def test_H2(self):
        op_H2_1D = selection.H2(self.domain_shape_1D)
        queries = op_H2_1D.select()

        self.assertEqual(queries.shape[0], 31)
        self.assertEqual(queries.shape[1], 16)