Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weight file problem #39

Open
ztyf-lq opened this issue Mar 25, 2024 · 3 comments
Open

weight file problem #39

ztyf-lq opened this issue Mar 25, 2024 · 3 comments

Comments

@ztyf-lq
Copy link

ztyf-lq commented Mar 25, 2024

Hello, I have carefully read your wonderful and unparalleled article. But while running the article code, I found that your weight file on the cloud drive is damaged. Could you please update the weight file on the cloud drive?

@lliutianc
Copy link

The issue comes from that the checkpoints didn't use module but initialized one does. So the key names don't match.

Manually updated key names should be a quick fix. For example, add below snippets to the resume function in BaseModel

        new_stat = {}
        for key, val in current_checkpoint['state_dict'].items():
            if "module" not in key:
                new_key = key.split(".")
                new_key.insert(1, "module")
                new_key = ".".join(new_key)
                new_stat[new_key] = val
            else:
                new_stat[key] = val
        current_checkpoint['state_dict'] = new_stat

somewhere between

        current_checkpoint = torch.load(resume_path)

and

        self.model.load_state_dict(current_checkpoint['state_dict'], strict=True)

should work.

@ztyf-lq
Copy link
Author

ztyf-lq commented Apr 26, 2024

Thank you for your answer. My question is that there was an error in decompressing the weight file after downloading, not during loading. Thank you again

@lliutianc
Copy link

Oh never mind, I didn't encounter any issue with the checkpoint downloaded from google drive. Probably have a try again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants