RuntimeError: Error(s) in loading state_dict for XXXXXX:

created at 12-06-2021 views: 11

error

RuntimeError: Error(s) in loading state_dict for SwinUnet

First check whether the num_classes, batch_size, and epoch in train.py are the same as test.py, and if they are different, modify them to be the same. It might succeed.

If it doesn't work:

Find the error code statement as

msg = net.load_state_dict(torch.load(model_para_path))

changed to:

msg = net.load_state_dict(torch.load(model_para_path),False)

Find the error code statement as net.load_state_dict(torch.load(model_para_path))
According to the above method, it does not work if it is modified to false, and then it runs normally after commenting out this sentence.

Although the above two methods work normally, the results are not satisfactory. I still don’t know how to modify it. I hope you can correct me.

created at:12-06-2021
edited at: 12-06-2021: