nnUNet icon indicating copy to clipboard operation
nnUNet copied to clipboard

dumb_trainer_config_plans_to_trained_models_dict() is creating too much model_dict for find_best_configuration()

Open ShadowTwin41 opened this issue 1 year ago • 1 comments

When running: nnUNetv2_find_best_configuration 123 -c 3d_fullres 3d_fullres_other -tr nnUNetTrainer nnUNetTrainer_other I get: model_dict = ({'plans': 'nnUNetPlans', 'configuration': '3d_fullres', 'trainer': 'nnUNetTrainer'}, {'plans': 'nnUNetPlans', 'configuration': '3d_fullres_other', 'trainer': 'nnUNetTrainer'}, {'plans': 'nnUNetPlans', 'configuration': '3d_fullres', 'trainer': 'nnUNetTrainer_other'}, {'plans': 'nnUNetPlans', 'configuration': '3d_fullres_other', 'trainer': 'nnUNetTrainer_other'}).

But this is not correct, this should be:

model_dict = ({'plans': 'nnUNetPlans', 'configuration': '3d_fullres', 'trainer': 'nnUNetTrainer'}, {'plans': 'nnUNetPlans', 'configuration': '3d_fullres_other', 'trainer': 'nnUNetTrainer_other'}).

Am I doing something wrong?

I think the function dumb_trainer_config_plans_to_trained_models_dict is wrong.

def dumb_trainer_config_plans_to_trained_models_dict(trainers: List[str], configs: List[str], plans: List[str]):
    """
    function is called dumb because it's dumb
    """
    ret = []
    for t in trainers:
        for c in configs:
            for p in plans:
                ret.append(
                    {'plans': p, 'configuration': c, 'trainer': t}
                )
    return tuple(ret)

ShadowTwin41 avatar Jun 27 '23 17:06 ShadowTwin41

I have a solution to this problem, but it requires entering all the plans and trainers for each configuration.

def dumb_trainer_config_plans_to_trained_models_dict(trainers: List[str], configs: List[str], plans: List[str]):
    """
    function is called dumb because it's dumb
    """
    ret = []
    for index, c in enumerate(configs):
        p = plans[index]
        t = trainers[index]
        ret.append({'plans': p, 'configuration': c, 'trainer': t})
    return tuple(ret)

ShadowTwin41 avatar Jun 27 '23 17:06 ShadowTwin41