o  i¾ã@sFddlmZddlmZddlmZGdd„dƒZGdd„deƒZdS) é)Ú annotations)ÚPathLike)Ú Randomizablec@sFeZdZUdZdZded<dd„Zdd„Zd d „Zd d „Z d d„Z dS)Ú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. NzPathLike | NoneÚ template_pathcOódS)z\Provide dataset (and summaries) so that the model creation can depend on the input datasets.N©©ÚselfÚargsÚkwargsrrúZ/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/auto3dseg/algo_gen.pyÚset_data_statsózAlgo.set_data_statscOr)z1Read training/validation data and output a model.Nrr rrr Útrainrz Algo.traincOr)z,Read test data and output model predictions.Nrr rrr Úpredict"rz Algo.predictcOr)zPReturns the model quality measurement based on training and validation datasets.Nrr rrr Ú get_score&rzAlgo.get_scorecOr)z2Returns the algo output paths for scripts locationNrr rrr Úget_output_path*rzAlgo.get_output_path) Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ__annotations__rrrrrrrrr rs   rc@sPeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dS)Ú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). cOr)zdProvide dataset summaries/properties so that the generator can be conditioned on the input datasets.Nrr rrr rGrzAlgoGen.set_data_statscOr)ziProvide computational budget so that the generator outputs algorithms that requires reasonable resources.Nrr rrr Ú set_budgetKrzAlgoGen.set_budgetcOr)z\Feedback from the previously generated algo, the score can be used for new Algo generations.Nrr rrr Ú set_scoreOrzAlgoGen.set_scorecOr)zGet current dataset summaries.Nrr rrr Úget_data_statsSrzAlgoGen.get_data_statscOr)z%Get the current computational budget.Nrr rrr Ú get_budgetWrzAlgoGen.get_budgetcOr)z"Get the previously generated algo.Nrr rrr Ú get_history[rzAlgoGen.get_historycCr)z[Generate new Algo -- based on data_stats, budget, and history of previous algo generations.Nr)r rrr Úgenerate_rzAlgoGen.generatecOr)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. Nrr rrr Úrun_algocszAlgoGen.run_algoN) rrrrrrrrrrrr rrrr r/s rN)Ú __future__rÚ monai.configrÚmonai.transformsrrrrrrr Ús