o
     i¾  ã                   @  sF   d dl mZ d dlmZ d dlmZ G dd„ dƒZG dd„ deƒZdS )	é    )Úannotations)ÚPathLike)ÚRandomizablec                   @  sF   e Zd ZU dZdZded< dd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )ÚAlgozÓ
    An algorithm in this context is loosely defined as a data processing pipeline consisting of multiple components
    such as image preprocessing, followed by deep learning model training and evaluation.
    NzPathLike | NoneÚtemplate_pathc                 O  ó   dS )z\Provide dataset (and summaries) so that the model creation can depend on the input datasets.N© ©ÚselfÚargsÚkwargsr   r   úZ/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/auto3dseg/algo_gen.pyÚset_data_stats   ó   zAlgo.set_data_statsc                 O  r   )z1Read training/validation data and output a model.Nr   r	   r   r   r   Útrain   r   z
Algo.trainc                 O  r   )z,Read test data and output model predictions.Nr   r	   r   r   r   Úpredict"   r   zAlgo.predictc                 O  r   )zPReturns the model quality measurement based on training and validation datasets.Nr   r	   r   r   r   Ú	get_score&   r   zAlgo.get_scorec                 O  r   )z2Returns the algo output paths for scripts locationNr   r	   r   r   r   Úget_output_path*   r   zAlgo.get_output_path)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r   r   r   r   r   r   r   r   r      s   
 r   c                   @  sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚAlgoGena3  
    A data-driven algorithm generator. It optionally takes the following inputs:

        - training dataset properties (such as data statistics from ``monai.auto3dseg.analyzer``),
        - previous algorithm's scores measuring the model quality,
        - computational budgets,

    and generates ``Algo`` instances. The generated algos are to be trained with the training datasets::

                                  scores
                        +------------------------+
                        |   +---------+          |
        +-----------+   +-->|         |    +-----+----+
        | Dataset,  |       | AlgoGen |--->|   Algo   |
        | summaries |------>|         |    +----------+
        +-----+-----+       +---------+          ^
              |                                  |
              +----------------------------------+

    This class also maintains a history of previously generated Algo and their corresponding validation scores.
    The Algo generation process may be stochastic (using ``Randomizable.R`` as the source random state).
    c                 O  r   )zdProvide dataset summaries/properties so that the generator can be conditioned on the input datasets.Nr   r	   r   r   r   r   G   r   zAlgoGen.set_data_statsc                 O  r   )ziProvide computational budget so that the generator outputs algorithms that requires reasonable resources.Nr   r	   r   r   r   Ú
set_budgetK   r   zAlgoGen.set_budgetc                 O  r   )z\Feedback from the previously generated algo, the score can be used for new Algo generations.Nr   r	   r   r   r   Ú	set_scoreO   r   zAlgoGen.set_scorec                 O  r   )zGet current dataset summaries.Nr   r	   r   r   r   Úget_data_statsS   r   zAlgoGen.get_data_statsc                 O  r   )z%Get the current computational budget.Nr   r	   r   r   r   Ú
get_budgetW   r   zAlgoGen.get_budgetc                 O  r   )z"Get the previously generated algo.Nr   r	   r   r   r   Úget_history[   r   zAlgoGen.get_historyc                 C  r   )z[Generate new Algo -- based on data_stats, budget, and history of previous algo generations.Nr   )r
   r   r   r   Úgenerate_   r   zAlgoGen.generatec                 O  r   )aÎ  
        Launch the Algos. This is useful for light-weight Algos where there's no need to distribute the training jobs.

        If the generated Algos require significant scheduling of parallel executions, a job scheduler/controller
        implemented separately is preferred to run them. In this case the controller should also report back the
        scores and the algo history, so that the future ``AlgoGen.generate`` can leverage the information.
        Nr   r	   r   r   r   Úrun_algoc   s   zAlgoGen.run_algoN)r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r   /   s    r   N)Ú
__future__r   Úmonai.configr   Úmonai.transformsr   r   r   r   r   r   r   Ú<module>   s
   