Save Finetuned XLM-RoBERTa on Tf-Keras
I am finetuning XLM-RoBERTa for text classification. I am finetuning model on Tensorflow-keras. I have trained model on google colab GPU.  I used below save method from keras as shown below to save my model. 

```
model.save("/content/drive/MyDrive/TrainedModel")
loaded_model = tf.keras.models.load_model("/content/drive/MyDrive/TrainedModel")
```

It saves saved model but gives below error when loading the model on CPU. How can I load model to run it?

[/usr/local/lib/python3.7/dist-packages/tensorflow/python/training/py_checkpoint_reader.py](https://localhost:8080/#) in get_tensor(self, tensor_str)
     65   try:
     66     return CheckpointReader.CheckpointReader_GetTensor(
---> 67         self, compat.as_bytes(tensor_str))
     68   # TODO(b/143319754): Remove the RuntimeError casting logic once we resolve the
     69   # issue with throwing python exceptions from C++.
** IndexError: Read less bytes than requested**

I got below warning when saving the model using above function. The saved model size is 7.43 MB. 

WARNING:absl:Found untraced functions such as encoder_layer_call_fn, encoder_layer_call_and_return_conditional_losses, embeddings_layer_call_fn, embeddings_layer_call_and_return_conditional_losses, dense_layer_call_fn while saving (showing 5 of 422). These functions will not be directly callable after loading.
INFO:tensorflow:Assets written to: /content/drive/MyDrive/TrainedModel/assets
INFO:tensorflow:Assets written to: /content/drive/MyDrive/TrainedModel/assets
cc @gante @Rocketknight1 <|||||>Hi @Komalrathod55 👋 The `.save` method saves a myriad of TensorFlow-related objects, which may be tricky to serialize and/or load due to our complex architectures. We recommend using TF's `model.save_weights("some_folder/your_model_name.h5")` (with the `.h5` file extension) to store the weights, and then our `.from_pretrained("some_folder")` model class method to restore them.

Let me know if this solves your issue :)<|||||>Hi @gante , Thank you for your response. I tried the solution provided by you. But I was getting error regarding config file and model name.

1. OSError: Error no file named tf_model.h5 found in directory 
2. file some_folder/config.json not found

 So I renamed model as tf_model.h5 and put config.json in "some_folder".

This works well but this model runs very slow. The time to process a single file is 3.6 seconds. Can you let me know your insights about this issue? Thank you.<|||||>My apologies, I should have mentioned that the model must be named `tf_model.h5` -- I'm glad that it runs now. As for speed, I'm afraid we'll need more details -- for instance, if you are trying to run `model.generate()`, speed is a known issue that we are addressing at the moment.

Since the goal of these issues is to report and solve potential bugs, which we've discarded, I'd like to ask you to move the conversation to [our forum](https://discuss.huggingface.co/), where our members and the community can pitch in with solutions. 