about resnet18 implementation & several related questions

550 views
Skip to first unread message

Melvin Selim Atay

unread,
Feb 8, 2022, 2:58:25 AM2/8/22
to Clinica
Hi
I have managed to train "default" model FC I presume it is  Conv5_FC3 https://github.com/aramis-lab/clinicadl/blob/master/clinicadl/utils/network/cnn/models.py#L27 on t1-linear processed AD for classification task. I am asking this question before checking the outputs but I am curious if it prints model performance metrics like accuracy, f1 & such. Documentation says it does do I need to invoke any parameter to call them?
My second question is about resnet18 model when I tried to replace default model with "resnet18" I get RuntimeError: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [1, 1, 169, 208, 179] error not sure if its from pytorch side and what should I do to prevent.
Adding to this my custom model is a variant of a resnet if I add my implementation to model.py file or a different py file but directing how to reach it from model.py documentation says it is theoretically possible what should I keep in mind.
Thanks for your help & huge endeavor on reproducible research.

Ravi Hassanaly

unread,
Feb 9, 2022, 5:03:46 AM2/9/22
to Clinica
Hi, 
Thanks for your interest in ClinicaDL.

Indeed default model for classification task is Conv5_FC3. For classification task default metrics used for evaluation are accuracy, sensitivity, specificity, Positive Predictive Value, Negative Predictive Value and Balanced Accuracy. That is to say those metrics will be automatically computed for training and validation sets in the end of the training phase and if you use `clinicadl predict` on your test sets.

Concerning the resnet18 model, it looks like you are training your model on 3 volumes, which makes 5D batches (1 dimension for the batch, 1 for the channel and 3 for the image). However default resnet18 model from Pytorch is a 2D model (with 2D convolution layers), this is why you have this error because it cannot handle 5D tensors (only 3D or 4D). If you want to to use the resnet18 model you can extract 2D slices from your 3D image using `clinicadl extract slice` command.

To add your own Pytorch model, you have to follow the following guidelines: https://clinicadl.readthedocs.io/en/stable/Contribute/Custom/#custom-architecture. Your model class must inherit from clinicadl `Network` abstract class. Than it has to be imported in `clinicadl/utils/network/__init__.py` file to be detect by the command line. You should then be able to use it.

FYI a new version of ClinicaDL should be released by the end of the week, and we tried to make some of these points clearer.
You can also use github issues for questions related to ClinicaDL !

Ravi

Melvin Selim Atay

unread,
Feb 9, 2022, 11:26:40 PM2/9/22
to Clinica
Thanks Ravi,
I made an assumption that resnet18 version is already adapted for 3D volumes so it did not occur to me using 2D one, my bad!
Thanks for the tip, I'll be editing model implementation accordingly.
Super excited for the new version!
Reply all
Reply to author
Forward
0 new messages