🐛 Saving TF model : Expected Operation, Variable, or Tensor, got None
🐛 Bug
I'm training TFElectraModel. Training goes well, but when I try to save the model, I met the following error :
TypeError: Expected Operation, Variable, or Tensor, got None
Minimal reproducible example
!pip install transformers
from transformers import TFElectraModel
model = TFElectraModel.from_pretrained("google/electra-base-discriminator")
!mkdir swag
model.save("swag")
Related
#2336 https://github.com/tensorflow/tensorflow/issues/35432
Hi! We prefer using our own API for this, using from_pretrained which also takes care of the configuration:
from transformers import TFElectraModel
model = TFElectraModel.from_pretrained("google/electra-base-discriminator")
!mkdir swag
model.save_pretrained("swag")
Is there a reason why you would rather use .save rather than .save_pretrained?
I was using .save() because I made a custom model, with additional layers on top of Electra, and I want to save these layers as well.
Finally, I simply sub-classed TFElectraPreTrainedModel and add my custom layers there, so I can use .save_pretrained.
Thanks for the help !
I am also facing similar issue. The reason for using save method is i want to host the saved model using tensorflow model server
@nirajkale did you manage to solve this? I'm facing the same issue with other pre-trained.