I have run into this very weird and frustrating streak of errors in TensorFlow. I am using the Shakespeare text generator from this website: (https://www.tensorflow.org/tutorials/text/text_generation) and I got to import my own model and get it to work for my intended purposes the first two times, but then it started yielding the following errors:
ValueError: The same saveable will be restored with two names: ids_from_chars/_table/.ATTRIBUTES/table
I was able to solve this one with the advice from this link: https://github.com/tensorflow/tensorflow/issues/46867, which suggested that I changed a very specific line of code intended for devs:
"A hack that worked for me was to edit the module throwing the error i.e. changing line number 329 in the file /usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saving/saveable_object_util.py from"
if saveable.op in seen_ops:
to
if saveable.op is not None and saveable.op in seen_ops:
But then I got yet another error:
ValueError: Found zero restored functions for caller function.
From the alert, I suppose it means that TensorFlow is failing to save the model properly, so I tried using other TensorFlow versions such as 2.3, 2.4, and nightly (I am currently using this one), but they all yield some sort of error. I cannot downgrade any further because tf2.2 does not support the StringLookup() function, which I need. I am very stuck so I would appreciate some help.
Additional Info:
- I am not using Conda but rather another virtual environment: https://www.tensorflow.org/install/pip
- The model works just fine, but tf fails to import/export the model
- I already tried several ways of saving the model as a whole (model.save(), tf.saved_model.save(), tf.saved_model.load())
- I am not sure if I only need the weights, but if I can just do this then a quick explanation on how to do this would be great
Thanks!