Esempio n. 1
0
    def __init__(self, bandit):
        TheanoBanditAlgo.__init__(self, bandit)
        self.numpy_rng = numpy.random.RandomState(234)
        self.s_prior = IdxsValsList.fromlists(self.s_idxs, self.s_vals)
        self.s_n_train = tensor.lscalar('n_train')
        self.s_n_test = tensor.lscalar('n_test')
        self.y_obs = tensor.vector('y_obs')
        self.y_obs_var = tensor.vector('y_obs_var')
        self.x_obs_IVL = self.s_prior.new_like_self()

        self.cand_x = self.s_prior.new_like_self()
        self.cand_EI_thresh = tensor.scalar()

        self.init_kernels()
        self.init_gram_weights()
        self.params.extend(self.convex_coefficient_params)
        self.param_bounds.extend(self.convex_coefficient_params_bounds)

        self.s_big_param_vec = tensor.vector()
        ### assumes all variables are refinable
        ### assumes all variables are vectors
        n_elements_used = 0
        for k, iv in zip(self.kernels, self.cand_x):
            if self.is_refinable[k]:
                n_elements_in_v = iv.idxs.shape[0]
                start = n_elements_used
                stop = n_elements_used + n_elements_in_v
                iv.vals = self.s_big_param_vec[start:stop]
                n_elements_used += n_elements_in_v

        self.gprmath = GPR_math(self.x_obs_IVL,
                self.y_obs,
                self.y_obs_var,
                picklable_instancemethod(self, 'K_fn'),
                N=self.s_n_train,
                min_variance=self.y_minvar)

        self.nll_obs = self.gprmath.s_nll()
            
        self.cand_EI = tensor.log(self.gprmath.s_expectation_lt_thresh(
                    self.cand_x,
                    self.cand_EI_thresh))

        # self.gm_algo is used to draw candidates for subsequent refinement
        # It is also entirely responsible for choosing categorical variables.
        self.gm_algo = AdaptiveParzenGM(self.bandit)
        self.gm_algo.n_EI_candidates = self.n_candidates_to_draw_in_GM
Esempio n. 2
0
    def __init__(self, bandit):
        TheanoBanditAlgo.__init__(self, bandit)
        self.numpy_rng = numpy.random.RandomState(234)
        self.s_prior = IdxsValsList.fromlists(self.s_idxs, self.s_vals)
        self.s_n_train = tensor.lscalar('n_train')
        self.s_n_test = tensor.lscalar('n_test')
        self.y_obs = tensor.vector('y_obs')
        self.y_obs_var = tensor.vector('y_obs_var')
        self.x_obs_IVL = self.s_prior.new_like_self()

        self.cand_x = self.s_prior.new_like_self()
        self.cand_EI_thresh = tensor.scalar()

        self.init_kernels()
        self.init_gram_weights()
        self.params.extend(self.convex_coefficient_params)
        self.param_bounds.extend(self.convex_coefficient_params_bounds)

        self.s_big_param_vec = tensor.vector()
        ### assumes all variables are refinable
        ### assumes all variables are vectors
        n_elements_used = 0
        for k, iv in zip(self.kernels, self.cand_x):
            if self.is_refinable[k]:
                n_elements_in_v = iv.idxs.shape[0]
                start = n_elements_used
                stop = n_elements_used + n_elements_in_v
                iv.vals = self.s_big_param_vec[start:stop]
                n_elements_used += n_elements_in_v

        self.gprmath = GPR_math(self.x_obs_IVL,
                                self.y_obs,
                                self.y_obs_var,
                                picklable_instancemethod(self, 'K_fn'),
                                N=self.s_n_train,
                                min_variance=self.y_minvar)

        self.nll_obs = self.gprmath.s_nll()

        self.cand_EI = tensor.log(
            self.gprmath.s_expectation_lt_thresh(self.cand_x,
                                                 self.cand_EI_thresh))

        # self.gm_algo is used to draw candidates for subsequent refinement
        # It is also entirely responsible for choosing categorical variables.
        self.gm_algo = AdaptiveParzenGM(self.bandit)
        self.gm_algo.n_EI_candidates = self.n_candidates_to_draw_in_GM
Esempio n. 3
0
 def __init__(self, bandit, good_estimator, bad_estimator):
     TheanoBanditAlgo.__init__(self, bandit)
     self.good_estimator = good_estimator
     self.bad_estimator = bad_estimator
     self.build_helpers()
Esempio n. 4
0
 def __init__(self, bandit, good_estimator, bad_estimator):
     TheanoBanditAlgo.__init__(self, bandit)
     self.good_estimator = good_estimator
     self.bad_estimator = bad_estimator
     self.build_helpers()