T5 weights auto conversion from TF to PyTorch
Hi Great community, I am wondering: is there a script that help automatically convert TF weights (*.h5) to PyTorch weights (.bin) and from PyTorch to TF for T5?My goal is to use T5ForConditionalGeneration and TFT5ForConditionalGeneration interchangeably, i.e., I fine-tune a T5 model first in TF and then want to do inference with it in PyTorch.
2020-09-10T14:15:50Z
Here you go my friend -github.comhuggingface/transformers/blob/master/src/transformers/convert_t5_original_tf_checkpoint_to_pytorch.py# coding=utf-8
# Copyright 2018 The T5 authors and HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Convert T5 checkpoint."""


import argparse

import torchThis file has been truncated.show original