Bug Fix: pretrained s3prl-frontend based models loaded with parameters key mismatch error#5074
Conversation
|
Can you fix some CI errors? |
4b511f6 to
48904c7
Compare
|
Thanks, @simpleoier! |
…ers key mismatch error
48904c7 to
daf1233
Compare
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## master #5074 +/- ##
==========================================
- Coverage 75.86% 75.85% -0.02%
==========================================
Files 615 615
Lines 54689 54698 +9
==========================================
+ Hits 41491 41492 +1
- Misses 13198 13206 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
| device = f"cuda:{torch.cuda.current_device()}" | ||
| model.load_state_dict(torch.load(model_file, map_location=device)) | ||
| try: | ||
| model.load_state_dict(torch.load(model_file, map_location=device)) |
There was a problem hiding this comment.
Could you change this to
state_dict = torch.load(model_file, map_location=device)
try:
model.load_state_dict(state_dict)and remove the later call of torch.load?
|
Sorry for the late reply. Yes, the code works to load an old model. Thanks. Could that be fixed? (See my comment in the code) |
This is related to #4910 .
Thanks @boeddeker for the solution!