diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2023-07-05 13:06:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 13:06:33 +0100 |
commit | 93896f6596e44285f6250f4966ada8c08fa85f09 (patch) | |
tree | fee5a01b56231a6d1472fd925f76c73aa8b93ac0 /candle-examples/examples/whisper/extract_weights.py | |
parent | d8f75ceeaa4702b641a9f71ec348fc54a32f4cd7 (diff) | |
parent | bce28ab7938b27931fd51e59c8bcad37038e0337 (diff) | |
download | candle-93896f6596e44285f6250f4966ada8c08fa85f09.tar.gz candle-93896f6596e44285f6250f4966ada8c08fa85f09.tar.bz2 candle-93896f6596e44285f6250f4966ada8c08fa85f09.zip |
Merge branch 'main' into upgrade_bert
Diffstat (limited to 'candle-examples/examples/whisper/extract_weights.py')
-rw-r--r-- | candle-examples/examples/whisper/extract_weights.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/candle-examples/examples/whisper/extract_weights.py b/candle-examples/examples/whisper/extract_weights.py new file mode 100644 index 00000000..65602703 --- /dev/null +++ b/candle-examples/examples/whisper/extract_weights.py @@ -0,0 +1,13 @@ +# Get the checkpoint from +# https://openaipublic.azureedge.net/main/whisper/models/d3dd57d32accea0b295c96e26691aa14d8822fac7d9d27d5dc00b4ca2826dd03/tiny.en.pt + +import torch +from safetensors.torch import save_file + +data = torch.load("tiny.en.pt") +weights = {} +for k, v in data["model_state_dict"].items(): + weights[k] = v.contiguous() + print(k, v.shape, v.dtype) +save_file(weights, "tiny.en.safetensors") +print(data["dims"]) |