Closed dfalbel closed 3 years ago
Hi Daniel,
making hub feature_column compatible with the FeatureColumnV2 (FeatureColumn as opposed to _FeatureColumn) is a relatively new feature, a crucial part is implemented here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/feature_column/feature_column_v2.py#L312.
The reason why it fails for you is simply that the feature didn't get into TF2.0 beta release. Trying with !pip install tf-nightly-2.0-preview
should work.
Thanks very much @vbardiovskyg ! I wonder if it's just the daily buiuld that is not working, but I get a different error when I try to use the created layer:
RuntimeError: variable_scope dense_features_9/text_hub_module_embedding/module/ was unused but the corresponding name_scope was already taken.
Again, this is the complete code:
import tensorflow as tf
import tensorflow_hub as hub
feature_columns = [hub.text_embedding_column(key = "text", module_spec = "https://tfhub.dev/google/nnlm-en-dim128/1")]
embedding = tf.keras.layers.DenseFeatures(feature_columns = feature_columns)
input = {'text': tf.keras.layers.Input(shape = [1,], dtype = 'string')}
output = embedding(input)
And the colab link: https://colab.research.google.com/drive/1MDFr9fhUYO3QSDayVrBjJBehMzZH8Otq I tried with other models in thub.dev too and got the same error.
@dfalbel Were you able to get this working? Did you see #281?
@rjurney Not yet. I keep having these RuntimeError: variable_scope module_1/ was unused but the corresponding name_scope was already taken.
See this colab notebook: https://colab.research.google.com/drive/1MDFr9fhUYO3QSDayVrBjJBehMzZH8Otq
Hi Daniel and Russel, you are right, this actually seems broken now.
Any news regarding the bug or a workaround?
Yeah, it would be cool if this worked in 2.0.1
Do we have any solution working for this problem now?
hub.text_feature_column_v2 is expected to work with TF2.3 and up.
I just confirmed that the provided Colab works when using hub.text_embedding_column_v2
(and the current TF version).
Here's a small reproducible code with TF 2.0:
Errors with:
Here's the same code in colab:
https://colab.research.google.com/drive/1MDFr9fhUYO3QSDayVrBjJBehMzZH8Otq