You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import tensorflow as tf
inputs = keras.Input(shape=(None,), dtype="int64")
embedded = tf.one_hot(inputs, depth=max_tokens)
x = layers.Bidirectional(layers.LSTM(32))(embedded)
x = layers.Dropout(0.5)(x)
outputs = layers.Dense(1, activation="sigmoid")(x)
model = keras.Model(inputs, outputs)
model.compile(optimizer="rmsprop",
loss="binary_crossentropy",
metrics=["accuracy"])
model.summary()
But I am getting the following error:
/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/framework/op_def_library.py in _ExtractInputsAndAttrs(op_type_name, op_def, allowed_list_attr_map, keywords, default_type_attr_map, attrs, inputs, input_types)
570 values, as_ref=input_arg.is_ref).dtype.name
571 except ValueError as err:
--> 572 raise ValueError(
573 f"Tried to convert '{input_name}' to a tensor and failed. "
574 f"Error: {err}")
ValueError: Tried to convert 'indices' to a tensor and failed. Error: A KerasTensor cannot be used as input to a TensorFlow function. A KerasTensor is a symbolic placeholder for a shape and dtype, used when constructing Keras Functional models or Keras Functions. You can only use it as input to a Keras layer or a Keras operation (from the namespaces keras.layers and keras.operations). You are likely doing something like:
x = Input(...)
...
tf_fn(x) # Invalid.
Can someone help me with this?
Thanks!
The text was updated successfully, but these errors were encountered:
text_vectorization = keras.layers.TextVectorization(
# output_sequence_length=max_length, this can be used with output mode other than int. You can keep it as is or truncate it manually
output_mode="one_hot",
max_tokens=max_tokens
)
I tried to run this file https://github.com/fchollet/deep-learning-with-python-notebooks/blob/master/chapter11_part02_sequence-models.ipynb and this section as the below:
import tensorflow as tf
inputs = keras.Input(shape=(None,), dtype="int64")
embedded = tf.one_hot(inputs, depth=max_tokens)
x = layers.Bidirectional(layers.LSTM(32))(embedded)
x = layers.Dropout(0.5)(x)
outputs = layers.Dense(1, activation="sigmoid")(x)
model = keras.Model(inputs, outputs)
model.compile(optimizer="rmsprop",
loss="binary_crossentropy",
metrics=["accuracy"])
model.summary()
But I am getting the following error:
/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/framework/op_def_library.py in _ExtractInputsAndAttrs(op_type_name, op_def, allowed_list_attr_map, keywords, default_type_attr_map, attrs, inputs, input_types)
570 values, as_ref=input_arg.is_ref).dtype.name
571 except ValueError as err:
--> 572 raise ValueError(
573 f"Tried to convert '{input_name}' to a tensor and failed. "
574 f"Error: {err}")
ValueError: Tried to convert 'indices' to a tensor and failed. Error: A KerasTensor cannot be used as input to a TensorFlow function. A KerasTensor is a symbolic placeholder for a shape and dtype, used when constructing Keras Functional models or Keras Functions. You can only use it as input to a Keras layer or a Keras operation (from the namespaces
keras.layers
andkeras.operations
). You are likely doing something like:x = Input(...)
...
tf_fn(x) # Invalid.
Can someone help me with this?
Thanks!
The text was updated successfully, but these errors were encountered: