Skip to content

QuickTuner - Image Classification#

QuickImageCLSTuner #

Bases: QuickTuner

QuickTuner for image classification.

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/tuners/image/classification/tuner.py
class QuickImageCLSTuner(QuickTuner):
    """QuickTuner for image classification.

    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")

        trial_info, metafeat = extract_image_dataset_metafeat(data_path)
        quick_opt.setup(n, metafeat=metafeat)

        self.trial_info = trial_info

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

    def run(
        self,
        fevals: int | None = None,
        time_budget: float | None = None,
        trial_info: dict | 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.
            trial_info (dict, optional): Additional information to pass to the objective function. 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 trial_info is not None:
            self.trial_info = trial_info
        return super().run(fevals=fevals, time_budget=time_budget, trial_info=self.trial_info)

run(fevals=None, time_budget=None, trial_info=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.

  • trial_info (dict, default: None ) –

    Additional information to pass to the objective function. 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/tuners/image/classification/tuner.py
def run(
    self,
    fevals: int | None = None,
    time_budget: float | None = None,
    trial_info: dict | 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.
        trial_info (dict, optional): Additional information to pass to the objective function. 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 trial_info is not None:
        self.trial_info = trial_info
    return super().run(fevals=fevals, time_budget=time_budget, trial_info=self.trial_info)