Thank you very much for your reply. I changed the code to the following.
if os.path.isfile(CKPT_PATH):
    print("=> loading checkpoint")
    checkpoint = torch.load(CKPT_PATH)
    substring = ‘module.’
    checkpoint_tmp = OrderedDict()
    for k in checkpoint:
        new_k = k[len(substring):] if k.startswith(substring) else k
        checkpoint_tmp[new_k] = checkpoint[k]
    checkpoint = checkpoint_tmp
    model.load_state_dict(checkpoint[‘state_dict’])
    print("=> loaded checkpoint")
else:
    print("=> no checkpoint found")
But it’s still the same error. What do you think is the reason?