vigsivan / RWCNet

Official implementation of Recurrence with Correlation Network for Medical Image Registration
MIT License
8 stars 4 forks source link

size mismatch for update.encoder.convc1.weight: #3

Closed animesh-007 closed 1 year ago

animesh-007 commented 1 year ago

Hi, I am trying to reproduce the results on the OASIS dataset, but I am getting the following error while loading the weights from stage 2 for training stage 3

RuntimeError: Error(s) in loading state_dict for SomeNet: size mismatch for update.encoder.convc1.weight: 
copying a param with shape torch.Size([8, 343, 1, 1, 1]) from checkpoint, the shape in current model is 
torch.Size([8, 125, 1, 1, 1]).
vigsivan commented 1 year ago

Hi @animesh-007 , can you share your training config and can you also share what command you used to run training?

animesh-007 commented 1 year ago

@vigsivan This is my training config file.

{
    "stages": [
        {
            "res_factor": 4,
            "patch_factor": 4,
            "iters": 12,
            "search_range": 3,
            "steps": 15000,
            "diffeomorphic": true,
            "start_from_last": false
        },
        {
            "res_factor": 2,
            "patch_factor": 4,
            "iters": 12,
            "search_range": 3,
            "steps": 20000,
            "diffeomorphic": true,
            "start_from_last": true
        },
        {
            "res_factor": 1,
            "patch_factor": 2,
            "iters": 4,
            "search_range": 2,
            "steps": 5000,
            "diffeomorphic": true,
            "start_from_last": false
        }
    ],
    "cache_file": "stage2.pkl",
    "savedir": "redoNLST"
}

I am using the following command to run python l2r_train_eval.py l2r_dataset_json.json train_config.json

vigsivan commented 1 year ago

Hi @animesh-007 , I wasn't able to reproduce your error. I have uploaded weights and the data split I used for OASIS inside train_oasis if it makes things easier for you. I have also refactored the codebase so I might have fixed the issue that you came across.

Thanks!

animesh-007 commented 1 year ago

Hi @vigsivan, Thank you for helping. I have one follow-up question. Here the search range is 2 train_config.json so should it be 3 or 2 only? I tried changing it to 3, and I was getting no error in that case.

Since we are loading weights from stage 2 which has search range 3, I think this was the main reason for the error. Can you verify my understanding?

vigsivan commented 1 year ago

^Yep the search range needs to be consistent in order to load weights.