Load fine tuned model in tensorflow
I fine-tuned a  pre-trained model(wav2vec) in hugging face using the transformers library and converted it from PyTorch to Tensorflow. I want to load this fine-tuned model in Tensorlfow but I can’t seem to find any tutorials showcasing how to. Any help would be appreciated.
2021-08-03T10:59:49Z
from transformers import TFWav2Vec2ForXxx

TFWav2Vec2ForXxx.from_pretrained(model_name_or_path)wheremodel_name_or_pathis the folder where you stored that model, or the name of the repo you pushed it to on the Hugging Face Hub.
2021-08-03T13:12:46Z
How would i load this model in tensorflow , wouldn’t this be loading it using huggingface ?
2021-08-03T16:06:25Z
The TensorFlow library does not offer an implementation of the Wav2Vec2 model, so I’m not sure how you would like to be loading it without using Transformers.
2021-08-03T16:17:04Z
https://tfhub.dev/vasudevgupta7/wav2vec2/1well there is this
2021-08-03T16:19:39Z
This is one particular model, not the architecture. Since the person that added it to the TF Hub is a core contributor to Transformers, it’s probably the same code as in the library behind it.
2021-08-03T16:23:44Z
okay thank you i am going to try to retrain the model in pure tenserflow
2021-08-03T16:35:59Z
I’m not sure you need to, you can save the model loaded as above in any pure TF format you want. As you would when retraining the model in pure TensorFlow.
2021-08-03T16:45:59Z
Well my main goal is to be able to load the wav2vec model inside tensorflow and after training a pytroch model inside hugging face and converting it to tensorflow I get a h5 file and a seperate config file .image1892×638 50.5 KBwhen I try to load it like this it gives me this error but when I try running this notebook:https://colab.research.google.com/github/vasudevgupta7/gsoc-wav2vec2/blob/main/notebooks/wav2vec2_saved_model_finetuning.ipynbwhich is the wav2vec model the guy upload to tensorflow this part works :image778×188 7.1 KBsoo Idk what’s wrong with this .Thank you for being patient with me
2021-08-03T16:56:03Z
As I said, first load it inside aTFWav2Vec2ForXxxmodel (I’m not sure exactly which model you used, replaced the Xxx to the proper name). You can do this withTFWav2Vec2ForXxx.from_pretrained(path_to_pytorch_model, from_pt=True)This model will be a Keras model. You can save it using Keras, so should be able to then load it with Keras.
2021-08-03T16:56:48Z
okay thank you i will try this i am sorry for wasting ur time
2021-08-03T17:15:32Z
I tried it :image1822×748 66.9 KBI tried this way too :image1829×619 52.5 KB