U ŒPÓh¾ã@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_pathcOsdS)z\Provide dataset (and summaries) so that the model creation can depend on the input datasets.N©©ÚselfÚargsÚkwargsrrúM/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/auto3dseg/algo_gen.pyÚset_data_statsszAlgo.set_data_statscOsdS)z1Read training/validation data and output a model.Nrrrrr Útrainsz Algo.traincOsdS)z,Read test data and output model predictions.Nrrrrr Úpredict"sz Algo.predictcOsdS)zPReturns the model quality measurement based on training and validation datasets.Nrrrrr Ú get_score&szAlgo.get_scorecOsdS)z2Returns the algo output paths for scripts locationNrrrrr Úget_output_path*szAlgo.get_output_path) Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ__annotations__r rrrrrrrr 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). cOsdS)zdProvide dataset summaries/properties so that the generator can be conditioned on the input datasets.Nrrrrr r GszAlgoGen.set_data_statscOsdS)ziProvide computational budget so that the generator outputs algorithms that requires reasonable resources.Nrrrrr Ú set_budgetKszAlgoGen.set_budgetcOsdS)z\Feedback from the previously generated algo, the score can be used for new Algo generations.Nrrrrr Ú set_scoreOszAlgoGen.set_scorecOsdS)zGet current dataset summaries.Nrrrrr Úget_data_statsSszAlgoGen.get_data_statscOsdS)z%Get the current computational budget.Nrrrrr Ú get_budgetWszAlgoGen.get_budgetcOsdS)z"Get the previously generated algo.Nrrrrr Ú get_history[szAlgoGen.get_historycCsdS)z[Generate new Algo -- based on data_stats, budget, and history of previous algo generations.Nr)r rrr Úgenerate_szAlgoGen.generatecOsdS)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. Nrrrrr Úrun_algocszAlgoGen.run_algoN) rrrrr rrrrrrrrrrr r/srN)Ú __future__rÚ monai.configrÚmonai.transformsrrrrrrr Ú s