Skip to content

Commit

Permalink
Merge pull request #2 from zzasdf/k2ssl-util
Browse files Browse the repository at this point in the history
checkpoint convert script
  • Loading branch information
yfyeung authored Mar 19, 2024
2 parents ea0b631 + ac73f60 commit 482c24e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions egs/librispeech/SSL/local/convert_checkpoint_from_fairseq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# simple script to convert a fairseq checkpoint into pytorch parameter state dict
from argparse import ArgumentParser
from collections import OrderedDict

import torch

parser = ArgumentParser()
parser.add_argument("--src")
parser.add_argument("--tgt")

args = parser.parse_args()
src = args.src
tgt = args.tgt

old_checkpoint = torch.load(src)
new_checkpoint = OrderedDict()
new_checkpoint["model"] = old_checkpoint["model"]
torch.save(new_checkpoint, tgt)

0 comments on commit 482c24e

Please sign in to comment.