From fc74c845377adcb292103b73b63fcd5e02f5c08f Mon Sep 17 00:00:00 2001 From: Lucien Date: Mon, 13 Dec 2021 23:31:11 +0800 Subject: [PATCH] Swap TF and PT code inside two blocks (#14742) --- docs/source/quicktour.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/quicktour.mdx b/docs/source/quicktour.mdx index f3e5c7f2fa..90ba300e54 100644 --- a/docs/source/quicktour.mdx +++ b/docs/source/quicktour.mdx @@ -334,21 +334,21 @@ PyTorch and TensorFlow: any model saved as before can be loaded back either in P If you would like to load your saved model in the other framework, first make sure it is installed: ```bash -pip install tensorflow -===PT-TF-SPLIT=== pip install torch +===PT-TF-SPLIT=== +pip install tensorflow ``` Then, use the corresponding Auto class to load it like this: ```py ->>> from transformers import TFAutoModel ->>> tokenizer = AutoTokenizer.from_pretrained(pt_save_directory) ->>> tf_model = TFAutoModel.from_pretrained(pt_save_directory, from_pt=True) -===PT-TF-SPLIT=== >>> from transformers import AutoModel >>> tokenizer = AutoTokenizer.from_pretrained(tf_save_directory) >>> pt_model = AutoModel.from_pretrained(tf_save_directory, from_tf=True) +===PT-TF-SPLIT=== +>>> from transformers import TFAutoModel +>>> tokenizer = AutoTokenizer.from_pretrained(pt_save_directory) +>>> tf_model = TFAutoModel.from_pretrained(pt_save_directory, from_pt=True) ``` Lastly, you can also ask the model to return all hidden states and all attention weights if you need them: