# How to conver Pytorch model to Flax

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-conver-pytorch-model-to-flax%2F11847%3E%5C
**Category:** Models\
**Created:** [November 16, 2021, 6:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-conver-pytorch-model-to-flax%2F11847 "2021-11-16T06:19:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmad](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ahmad/32/13322_2.png) [@Ahmad](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAhmad)%5C
**Post date:** [November 16, 2021, 6:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-conver-pytorch-model-to-flax%2F11847%2F1 "2021-11-16T06:19:07Z")

</div>

I want to train a mT5 model on more data for a sepcific language, how can I resume training (not from scratch)? I found a training example in huggingface examples, but that is for flax and from scratch. If I change `FlaxT5ForConditionalGeneration` to `T5ForConditionalGenration` and load my pytorch mode, then would it work? If no, how can I convert my pytorch to flax so that I can use this code?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [November 16, 2021, 10:10am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-conver-pytorch-model-to-flax%2F11847%2F2 "2021-11-16T10:10:00Z")

</div>

I believe you can convert a model from one framework to the other as follows:

```auto
from transformers import T5ForConditionalGeneration

model = T5ForConditionalGeneration.from_pretrained(model_name, from_flax=True)

```
