Ejemplo n.º 1
0
	def get_initial_design_iteration(self, initial_design):
		# number of 'SH rungs'
		ns = initial_design.get_num_configs()[-len(self.budgets):]
		iteration = SuccessiveHalving(HPB_iter=-1, num_configs=ns, budgets=self.budgets[-len(ns):], config_sampler=self.config_generator.get_config, logger=self.logger, result_logger=self.result_logger)	
		for i, (config, origin) in zip(range(ns[0]), initial_design):
			iteration.add_configuration(config.get_dictionary(), {"model_based_pick": "initial design:" + origin})
		return iteration
Ejemplo n.º 2
0
    def get_next_iteration(self, iteration, iteration_kwargs={}):
        """
		BO-HB uses (just like Hyperband) SuccessiveHalving for each iteration.
		See Li et al. (2016) for reference.
		
		Parameters
		----------
			iteration: int
				the index of the iteration to be instantiated

		Returns
		-------
			SuccessiveHalving: the SuccessiveHalving iteration with the
				corresponding number of configurations
		"""

        # number of 'SH rungs'
        s = self.max_SH_iter - 1 - (iteration % self.max_SH_iter)
        # number of configurations in that bracket
        n0 = int(np.floor((self.max_SH_iter) / (s + 1)) * self.eta**s)
        ns = [max(int(n0 * (self.eta**(-i))), 1) for i in range(s + 1)]

        return (SuccessiveHalving(
            HPB_iter=iteration,
            num_configs=ns,
            budgets=self.budgets[(-s - 1):],
            config_sampler=self.config_generator.get_config,
            **iteration_kwargs))
Ejemplo n.º 3
0
    def get_next_iteration(self, iteration, iteration_kwargs={}):
        # number of 'SH rungs'
        s = self.max_SH_iter - 1
        # number of configurations in that bracket
        n0 = int(np.floor((self.max_SH_iter) / (s + 1)) * self.eta ** s)
        ns = [max(int(n0 * (self.eta ** (-i))), 1) for i in range(s + 1)]

        return (SuccessiveHalving(HPB_iter=iteration, num_configs=ns,
                                  budgets=self.budgets[(-s - 1):],
                                  config_sampler=self.config_generator.get_config,
                                  **iteration_kwargs))
Ejemplo n.º 4
0
    def _make_iteration(self, iteration):
        ss = self.max_sh_iter - 1 - (iteration % self.max_sh_iter)

        # number of configurations in that bracket
        n0 = int(np.floor((self.max_sh_iter) / (ss + 1)) * self.eta**ss)
        ns = [max(int(n0 * (self.eta**(-i))), 1) for i in range(ss + 1)]

        return SuccessiveHalving(
            HPB_iter=iteration,
            num_configs=ns,
            budgets=self.budgets[(-ss - 1):],
            config_sampler=self.bohb.get_config,
        )
Ejemplo n.º 5
0
    def get_next_iteration(self, iteration, iteration_kwargs={}):
        """
			BO-HB uses (just like Hyperband) SuccessiveHalving for each iteration.
			See Li et al. (2016) for reference.
			
			Parameters:
			-----------
				iteration: int
					the index of the iteration to be instantiated

			Returns:
			--------
				SuccessiveHalving: the SuccessiveHalving iteration with the
					corresponding number of configurations
		"""

        min_budget = max(self.min_budget,
                         self.config_generator.largest_budget_with_model())
        max_budget = self.max_budget
        eta = self.eta

        # precompute some HB stuff
        max_SH_iter = -int(np.log(min_budget / max_budget) / np.log(eta)) + 1
        budgets = max_budget * np.power(
            eta, -np.linspace(max_SH_iter - 1, 0, max_SH_iter))

        # number of 'SH rungs'
        s = max_SH_iter - 1
        # number of configurations in that bracket
        n0 = int(np.floor((self.max_SH_iter) / (s + 1)) * eta**s)
        ns = np.array([max(int(n0 * (eta**(-i))), 1) for i in range(s + 1)])

        while (ns * budgets[-s - 1:]).sum() <= self.budget_per_iteration:
            n0 += 1
            ns = np.array(
                [max(int(n0 * (eta**(-i))), 1) for i in range(s + 1)])

        n0 -= 1
        ns = np.array([max(int(n0 * (eta**(-i))), 1) for i in range(s + 1)])

        assert (ns * budgets[-s - 1:]).sum(
        ) <= self.budget_per_iteration, 'Sampled iteration exceeds the budget per iteration!'

        return (SuccessiveHalving(
            HPB_iter=iteration,
            num_configs=ns,
            budgets=budgets,
            config_sampler=self.config_generator.get_config,
            **iteration_kwargs))
Ejemplo n.º 6
0
    def get_next_iteration(self, iteration, iteration_kwargs={}):
        """Returns a SH iteration with only evaluations on the biggest budget.
            Not related to NES. It is only to be compatible with hpbandster.

        Args:
            iteration        (int): the index of the iteration to be instantiated
            iteration_kwargs (dict): kwargs to be added to the instantiation of
                each iteration

        Returns:
            SuccessiveHalving: the SuccessiveHalving iteration with the
                corresponding number of configurations
        """

        budgets = [self.max_budget]
        ns = [self.budget_per_iteration // self.max_budget]

        return (SuccessiveHalving(HPB_iter=iteration, num_configs=ns, budgets=budgets,
                                  config_sampler=self.config_generator.get_config,
                                  **iteration_kwargs))
Ejemplo n.º 7
0
    def get_next_iteration(self, iteration, iteration_kwargs={}):
        """
		Returns a SH iteration with only evaluations on the biggest budget
		
		Parameters
		----------
			iteration: int
				the index of the iteration to be instantiated

		Returns
		-------
			SuccessiveHalving: the SuccessiveHalving iteration with the
				corresponding number of configurations
		"""

        budgets = [self.max_budget]
        ns = [self.budget_per_iteration // self.max_budget]

        return (SuccessiveHalving(
            HPB_iter=iteration,
            num_configs=ns,
            budgets=budgets,
            config_sampler=self.config_generator.get_config,
            **iteration_kwargs))