Repository: mlcommons/GaNDLF

Issue:
Add an error check for compute dimensions not supported by GaNDLF
### > I think the error message is caused by the yaml file. My input image size is 128 x 128 . 
> 
 **> this is error mesage  :**

`(venv_gandlf) C:\Users\pc\GaNDLF>python gandlf_run  -c ./images_and_labels/model.yaml -i ./images_and_labels/train.csv -m ./images_and_labels/model -t True -d cpu
WARNING: Initializing 'norm_type' as 'batch'
WARNING: Initializing 'verbose' as False
WARNING: Initializing 'medcam_enabled' as False
WARNING: Initializing 'save_training' as False
WARNING: Initializing 'save_output' as False
WARNING: Initializing 'in_memory' as False
WARNING: Initializing 'pin_memory_dataloader' as False
WARNING: Initializing 'enable_padding' as False
WARNING: Initializing 'scaling_factor' as 1
WARNING: Initializing 'clip_grad' as None
WARNING: Initializing 'track_memory_usage' as False
WARNING: Initializing 'print_rgb_label_warning' as True
WARNING: Initializing 'data_postprocessing' as {}
WARNING: Initializing 'grid_aggregator_overlap' as crop
WARNING: Initializing 'clip_mode' as None
WARNING: Setting default step_size to: 0.02
Trying to resume training without changing any parameters from previous run.
Using previously saved parameter file ./images_and_labels/model\parameters.pkl
Using previously saved testing data ./images_and_labels/model\testing_0\data_testing.pkl
Using previously saved training+validation data ./images_and_labels/model\testing_0\data_trainAndVal.pkl
Number of channels :  1
Constructing queue for train data: 100%|████████████████████████| 643/643 [00:02<00:00, 216.35it/s]
C:\Users\pc\anaconda3\envs\venv_gandlf\lib\site-packages\torch\utils\data\dataloader.py:477: UserWarning: This DataLoader will create 16 worker processes in total. Our suggested max number of worker in current system is 4 (`cpuset` is not taken into account), which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  cpuset_checked))
Calculating weights
Constructing queue for penalty data: 100%|██████████████████████| 643/643 [00:02<00:00, 241.46it/s]
Looping over training data for penalty calculation: 100%|███████| 643/643 [00:05<00:00, 121.90it/s]
Constructing queue for validation data: 100%|███████████████████| 161/161 [00:01<00:00, 124.04it/s]
All Keys :  ['subject_id', '1', 'spacing', 'label', 'path_to_metadata']
Traceback (most recent call last):
  File "gandlf_run", line 116, in <module>
    args.reset,
  File "C:\Users\pc\GaNDLF\GANDLF\cli\main_run.py", line 91, in main_run
    reset=reset,
  File "C:\Users\pc\GaNDLF\GANDLF\training_manager.py", line 254, in TrainingManager
    testing_data=testingData,
  File "C:\Users\pc\GaNDLF\GANDLF\compute\training_loop.py", line 239, in training_loop
    ) = create_pytorch_objects(params, training_data, validation_data, device)
  File "C:\Users\pc\GaNDLF\GANDLF\compute\generic.py", line 69, in create_pytorch_objects
    model = get_model(parameters)
  File "C:\Users\pc\GaNDLF\GANDLF\models\__init__.py", line 106, in get_model
    return global_models_dict[params["model"]["architecture"]](parameters=params)
  File "C:\Users\pc\GaNDLF\GANDLF\models\unet.py", line 41, in __init__
    conv=self.Conv,
  File "C:\Users\pc\anaconda3\envs\venv_gandlf\lib\site-packages\torch\nn\modules\module.py", line 948, in __getattr__
    type(self).__name__, name))
AttributeError: 'unet' object has no attribute 'Conv'`


**> And this is my yaml file**


[model.pdf](https://github.com/CBICA/GaNDLF/files/8631955/model.pdf)

_Originally posted by @HILALOZTEMEL in https://github.com/CBICA/GaNDLF/discussions/427_


Discussion:

Resolving patch:
diff --git a/GANDLF/models/modelBase.py b/GANDLF/models/modelBase.py
--- a/GANDLF/models/modelBase.py
+++ b/GANDLF/models/modelBase.py
@@ -78,6 +78,13 @@ def __init__(self, parameters):
             self.GlobalAvgPool = GlobalAveragePooling3D
             self.Norm = self.get_norm_type(self.norm_type.lower(), self.n_dimensions)
 
+        else:
+            raise ValueError(
+                "GaNDLF only supports 2D and 3D computations. {}D computations are not currently supported".format(
+                    self.n_dimensions
+                )
+            )
+
     def get_final_layer(self, final_convolution_layer):
         return get_modelbase_final_layer(final_convolution_layer)
 


Test patch: