def Run(self, W, x, eps, seed): x = x.flatten() prng = np.random.RandomState(seed) domain_size = np.prod(self.domain_shape) # Start with a uniform estimation of x x_hat = np.array([self.data_scale / float(domain_size)] * domain_size) W = get_matrix(W) if not isinstance(W, np.ndarray): W = W.toarray() measuredQueries = [] mult_weight = inference.MultiplicativeWeights(updateRounds = self.update_rounds) M_history = np.empty((0, domain_size)) y_history = [] for i in range(1, self.rounds+1): eps_round = eps / float(self.rounds) # SW worst_approx = pselection.WorstApprox(W, measuredQueries, x_hat, eps_round * self.ratio, 'EXPONENTIAL') M = worst_approx.select(x, prng) measuredQueries.append(M.mwem_index) if not isinstance(M, np.ndarray): M = M.toarray() # LM laplace = measurement.Laplace(M, eps_round * (1-self.ratio)) y = laplace.measure(x, prng) M_history = np.vstack([M_history, M]) y_history.extend(y) # MW if self.use_history: x_hat = mult_weight.infer(M_history, y_history, x_hat) else: x_hat = mult_weight.infer(M, y, x_hat) return x_hat
def Run(self, W, x, eps, seed): x = x.flatten() prng = np.random.RandomState(seed) domain_size = np.prod(self.domain_shape) # Start with a unifrom estimation of x x_hat = np.array([self.data_scale / float(domain_size)] * domain_size) W = get_matrix(W) W_partial = sparse.csr_matrix(W.shape) mult_weight = inference.MultiplicativeWeights(updateRounds = self.update_rounds) M_history = np.empty((0, domain_size)) y_history = [] for i in range(1, self.rounds+1): eps_round = eps / float(self.rounds) # SW worst_approx = pselection.WorstApprox(sparse.csr_matrix(W), W_partial, x_hat, eps_round * self.ratio, 'EXPONENTIAL') W_next = worst_approx.select(x, prng) M = support.extract_M(W_next) W_partial += W_next # LM laplace = measurement.Laplace(M, eps_round * (1-self.ratio)) y = laplace.measure(x, prng) M_history = sparse.vstack([M_history, M]) y_history.extend(y) # MW if self.use_history: x_hat = mult_weight.infer(M_history, y_history, x_hat) else: x_hat = mult_weight.infer(M, y, x_hat) return x_hat
def Run(self, W, x, eps, seed): x = x.flatten() prng = np.random.RandomState(seed) domain_size = np.prod(self.domain_shape) # Start with a unifrom estimation of x x_hat = np.array([self.data_scale / float(domain_size)] * domain_size) measuredQueries = [] mult_weight = inference.MultiplicativeWeights(updateRounds = self.update_rounds) M_history = [] y_history = [] for i in range(1, self.rounds+1): eps_round = eps / float(self.rounds) # SW + SH2 worst_approx = pselection.WorstApprox(W, measuredQueries, x_hat, eps_round * self.ratio) W_next = worst_approx.select(x, prng) measuredQueries.append(W_next.mwem_index) M = selection.AddEquiWidthIntervals(W_next, i).select() # LM laplace = measurement.Laplace(M, eps_round * (1-self.ratio)) y = laplace.measure(x, prng) M_history.append(M) y_history.append(y) # MW if self.use_history: x_hat = mult_weight.infer(M_history, y_history, x_hat) else: x_hat = mult_weight.infer(M, y, x_hat) return x_hat
def Run(self, W, x, eps, seed): prng = np.random.RandomState(seed) x_hat = prng.rand(*x.shape) W_partial = sparse.csr_matrix(W.get_matrix().shape) mult_weight = inference.MultiplicativeWeights() measured_queries = [] for i in range(1, self.rounds + 1): eps_round = eps / float(self.rounds) # SW + SH2 worst_approx = pselection.WorstApprox( sparse.csr_matrix(W.get_matrix()), W_partial, x_hat, eps_round * self.ratio) W_next = worst_approx.select(x, prng) M = selection.AddEquiWidthIntervals(W_next, i).select() W_partial += W_next laplace = measurement.Laplace(M, eps * (1 - self.ratio)) y = laplace.measure(x, prng) x_hat = mult_weight.infer(M, y, x_hat) return x_hat