Hi all,
I have a pandas DataFrame with features as columns and rows as observations. One of the columns is a Series where each element is a 512-long tf.Tensor. I am trying to pass this Tensor vector, along with the other features, into a tf.estimator.BoostedTreesClassifier model. However, I am receiving the following error when passing the tf.Tensor column:
AttributeError: Tensor.name is meaningless when eager execution is enabled.
Your help is much appreciated! Below is a reproducible example. Many thanks in advance for your help!
import pandas as pd
import tensorflow as tf
import tensorflow_hub as hub
df = pd.DataFrame({"Text": ['This is text one', 'This is text two', 'And well, this is just the third text']})
model_url = "https://tfhub.dev/google/universal-sentence-encoder/4"
encodings = tf.keras.Sequential(
[
tf.keras.layers.InputLayer(dtype=tf.string),
hub.KerasLayer(model_url, input_shape=[], dtype=tf.string),
]
)
def encodes_text(txt):
return encodings(tf.constant([txt]))
df['embeddings'] = df.map(lambda x: encodes_text(x))
tree_class = tf.estimator.BoostedTreesClassifier(
df.embedding,
max_depth=3,
n_classes=2,
n_trees,50,
n_batches_per_layer=1
)