Skip to content

CV-Classification-Tuner#

QuickTuner_CVCLS #

Bases: QuickTuner

QuickTuner for image classification tasks.

Parameters:

  • data_path (str) –

    Path to the dataset.

  • path (str, default: None ) –

    Path to save the optimizer. Defaults to None.

  • verbosity (int, default: 2 ) –

    Verbosity level. Defaults to 2.

Source code in src/qtt/tuner/cv_cls.py
class QuickTuner_CVCLS(QuickTuner):
    """QuickTuner for image classification tasks.

    Args:
        data_path (str): Path to the dataset.
        path (str, optional): Path to save the optimizer. Defaults to None.
        verbosity (int, optional): Verbosity level. Defaults to 2.
    """

    def __init__(
        self,
        data_path: str,
        n: int = 512,
        path: str | None = None,
        verbosity: int = 2,
    ):
        quick_opt: QuickOptimizer = get_pretrained_optimizer("mtlbm/full")

        task_info, metafeat = extract_task_info_metafeat(data_path)
        quick_opt.setup(n, metafeat=metafeat)

        self.task_info = task_info

        super().__init__(quick_opt, finetune_script, path=path, verbosity=verbosity)

    def run(
        self,
        task_info: dict | None = None,
        fevals: int | None = None,
        time_budget: float | None = None,
    ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
        """

        Args:
            fevals (int, optional): Number of function evaluations to run. Defaults to None.
            time_budget (float, optional): Time budget in seconds. Defaults to None.

        Returns:
            - np.ndarray: Trajectory of the incumbent scores.
            - np.ndarray: Runtime of the incumbent evaluations.
            - np.ndarray: History of all evaluations.
        """
        if task_info is not None:
            self.task_info = task_info
        return super().run(task_info=self.task_info, fevals=fevals, time_budget=time_budget)

run(task_info=None, fevals=None, time_budget=None) #

Parameters:

  • fevals (int, default: None ) –

    Number of function evaluations to run. Defaults to None.

  • time_budget (float, default: None ) –

    Time budget in seconds. Defaults to None.

Returns:

  • tuple[ndarray, ndarray, ndarray]
    • np.ndarray: Trajectory of the incumbent scores.
    • np.ndarray: Runtime of the incumbent evaluations.
    • np.ndarray: History of all evaluations.
Source code in src/qtt/tuner/cv_cls.py
def run(
    self,
    task_info: dict | None = None,
    fevals: int | None = None,
    time_budget: float | None = None,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
    """

    Args:
        fevals (int, optional): Number of function evaluations to run. Defaults to None.
        time_budget (float, optional): Time budget in seconds. Defaults to None.

    Returns:
        - np.ndarray: Trajectory of the incumbent scores.
        - np.ndarray: Runtime of the incumbent evaluations.
        - np.ndarray: History of all evaluations.
    """
    if task_info is not None:
        self.task_info = task_info
    return super().run(task_info=self.task_info, fevals=fevals, time_budget=time_budget)