src/orion/algo/tpe.py
def suggest(self, num=1):
        """Suggest a `num` of new sets of parameters. Randomly draw samples
        from the import space and return them.

        :param num: how many sets to be suggested.

        .. note:: New parameters must be compliant with the problem's domain
           `orion.algo.space.Space`.
        """
        if num > 1:
            raise ValueError("TPE should suggest only one point.")

        samples = []
        if len(self._trials_info) < self.n_initial_points:
            new_point = self.space.sample(
                1, seed=tuple(self.rng.randint(0, 1000000, size=3))
            )[0]
            samples.append(new_point)
        else:
            point = []
            below_points, above_points = self.split_trials()

            below_points = [flatten_dims(point, self.space) for point in below_points]
            above_points = [flatten_dims(point, self.space) for point in above_points]
            below_points = list(map(list, zip(*below_points)))
            above_points = list(map(list, zip(*above_points)))

            idx = 0
            for i, dimension in enumerate(self.space.values()):

                shape = dimension.shape
                if not shape:
                    shape = (1,)

                if dimension.type == "real":
                    points = self._sample_real_dimension(
                        dimension,
                        shape[0],
                        below_points[idx : idx + shape[0]],
                        above_points[idx : idx + shape[0]],
                    )
                elif (
                    dimension.type == "integer"
                    and dimension.prior_name == "int_uniform"
                ):
                    points = self.sample_one_dimension(
                        dimension,
                        shape[0],
                        below_points[idx : idx + shape[0]],
                        above_points[idx : idx + shape[0]],
                        self._sample_int_point,
                    )
                elif (
                    dimension.type == "categorical"
                    and dimension.prior_name == "choices"
                ):
                    points = self.sample_one_dimension(
                        dimension,
                        shape[0],
                        below_points[idx : idx + shape[0]],
                        above_points[idx : idx + shape[0]],
                        self._sample_categorical_point,
                    )
                elif dimension.type == "fidelity":
                    # fidelity dimension
                    points = [point[i] for point in self.space.sample(num)]
                else:
                    raise NotImplementedError()

                if len(points) < shape[0]:
                    logger.warning(
                        "TPE failed to sample new point with configuration %s",
                        self.configuration,
                    )
                    return None

                idx += shape[0]
                point += points

            point = regroup_dims(point, self.space)
            samples.append(point)

        return samples
Suggest a `num` of new sets of parameters. Randomly draw samples
        from the import space and return them.

        :param num: how many sets to be suggested.

        .. note:: New parameters must be compliant with the problem's domain
           `orion.algo.space.Space`.
        
Suggest a `num` of new sets of parameters. Randomly draw samples
from the import space and return them.
Suggest a ` num ` of new sets of parameters . Randomly draw samples from the import space and return them .
def suggest(self, num=1):
        if num > 1:
            raise ValueError("TPE should suggest only one point.")
        samples = []
        if len(self._trials_info) < self.n_initial_points:
            new_point = self.space.sample(
                1, seed=tuple(self.rng.randint(0, 1000000, size=3))
            )[0]
            samples.append(new_point)
        else:
            point = []
            below_points, above_points = self.split_trials()
            below_points = [flatten_dims(point, self.space) for point in below_points]
            above_points = [flatten_dims(point, self.space) for point in above_points]
            below_points = list(map(list, zip(*below_points)))
            above_points = list(map(list, zip(*above_points)))
            idx = 0
            for i, dimension in enumerate(self.space.values()):
                shape = dimension.shape
                if not shape:
                    shape = (1,)
                if dimension.type == "real":
                    points = self._sample_real_dimension(
                        dimension,
                        shape[0],
                        below_points[idx : idx + shape[0]],
                        above_points[idx : idx + shape[0]],
                    )
                elif (
                    dimension.type == "integer"
                    and dimension.prior_name == "int_uniform"
                ):
                    points = self.sample_one_dimension(
                        dimension,
                        shape[0],
                        below_points[idx : idx + shape[0]],
                        above_points[idx : idx + shape[0]],
                        self._sample_int_point,
                    )
                elif (
                    dimension.type == "categorical"
                    and dimension.prior_name == "choices"
                ):
                    points = self.sample_one_dimension(
                        dimension,
                        shape[0],
                        below_points[idx : idx + shape[0]],
                        above_points[idx : idx + shape[0]],
                        self._sample_categorical_point,
                    )
                elif dimension.type == "fidelity":
                    points = [point[i] for point in self.space.sample(num)]
                else:
                    raise NotImplementedError()
                if len(points) < shape[0]:
                    logger.warning(
                        "TPE failed to sample new point with configuration %s",
                        self.configuration,
                    )
                    return None
                idx += shape[0]
                point += points
            point = regroup_dims(point, self.space)
            samples.append(point)
        return samples
def suggest ( self , num = 1 ) : if num > 1 : raise ValueError ( "TPE should suggest only one point." ) samples = [ ] if len ( self . _trials_info ) < self . n_initial_points : new_point = self . space . sample ( 1 , seed = tuple ( self . rng . randint ( 0 , 1000000 , size = 3 ) ) ) [ 0 ] samples . append ( new_point ) else : point = [ ] below_points , above_points = self . split_trials ( ) below_points = [ flatten_dims ( point , self . space ) for point in below_points ] above_points = [ flatten_dims ( point , self . space ) for point in above_points ] below_points = list ( map ( list , zip ( * below_points ) ) ) above_points = list ( map ( list , zip ( * above_points ) ) ) idx = 0 for i , dimension in enumerate ( self . space . values ( ) ) : shape = dimension . shape if not shape : shape = ( 1 , ) if dimension . type == "real" : points = self . _sample_real_dimension ( dimension , shape [ 0 ] , below_points [ idx : idx + shape [ 0 ] ] , above_points [ idx : idx + shape [ 0 ] ] , ) elif ( dimension . type == "integer" and dimension . prior_name == "int_uniform" ) : points = self . sample_one_dimension ( dimension , shape [ 0 ] , below_points [ idx : idx + shape [ 0 ] ] , above_points [ idx : idx + shape [ 0 ] ] , self . _sample_int_point , ) elif ( dimension . type == "categorical" and dimension . prior_name == "choices" ) : points = self . sample_one_dimension ( dimension , shape [ 0 ] , below_points [ idx : idx + shape [ 0 ] ] , above_points [ idx : idx + shape [ 0 ] ] , self . _sample_categorical_point , ) elif dimension . type == "fidelity" : points = [ point [ i ] for point in self . space . sample ( num ) ] else : raise NotImplementedError ( ) if len ( points ) < shape [ 0 ] : logger . warning ( "TPE failed to sample new point with configuration %s" , self . configuration , ) return None idx += shape [ 0 ] point += points point = regroup_dims ( point , self . space ) samples . append ( point ) return samples
Suggest a `num` of new sets of parameters.
Suggest a ` num ` of new sets of parameters .
"""Suggest a `num` of new sets of parameters. Randomly draw samples
        from the import space and return them.

        :param num: how many sets to be suggested.

        .. note:: New parameters must be compliant with the problem's domain
           `orion.algo.space.Space`.
        """ # fidelity dimension
self
num
None