mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-08-26 10:16:14 +00:00
add checkpoint convert script
This commit is contained in:
parent
ea0b6311f1
commit
952abee88c
17
egs/librispeech/SSL/local/convert_checkpoint_from_fairseq.py
Normal file
17
egs/librispeech/SSL/local/convert_checkpoint_from_fairseq.py
Normal file
@ -0,0 +1,17 @@
|
||||
# simple script to convert a fairseq checkpoint into pytorch parameter state dict
|
||||
import torch
|
||||
from collections import OrderedDict
|
||||
from argparse import ArgumentParser
|
||||
|
||||
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)
|
Loading…
x
Reference in New Issue
Block a user