# T5 weights auto conversion from TF to PyTorch

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ft5-weights-auto-conversion-from-tf-to-pytorch%2F1072%3E%5C
**Category:** 🤗Transformers\
**Created:** [September 10, 2020, 11:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ft5-weights-auto-conversion-from-tf-to-pytorch%2F1072 "2020-09-10T11:37:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![congcongwang](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/congcongwang/32/3282_2.png) [@congcongwang](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcongcongwang)%5C
**Post date:** [September 10, 2020, 11:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ft5-weights-auto-conversion-from-tf-to-pytorch%2F1072%2F1 "2020-09-10T11:37:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![valhalla](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/valhalla/32/4179_2.png) [@valhalla](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvalhalla)%5C
**Post date:** [September 10, 2020, 2:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ft5-weights-auto-conversion-from-tf-to-pytorch%2F1072%2F2 "2020-09-10T14:15:50Z")

</div>

Here you go my friend -🙂

> <https://github.com/huggingface/transformers/blob/master/src/transformers/convert_t5_original_tf_checkpoint_to_pytorch.py>
