Error thrown at
def compute_mask(self, inputs, mask=None):
return tf.math.not_equal(inputs, 0)
Stacktrace
ValueError Traceback (most recent call last)
[<ipython-input-10-cf8901b39907>](https://localhost:8080/#) in <cell line: 6>()
4
5 encoder_inputs = keras.Input(shape=(None,), dtype="int64", name="encoder_inputs")
----> 6 x = PositionalEmbedding(sequence_length, vocab_size, embed_dim)(encoder_inputs)
7 encoder_outputs = TransformerEncoder(embed_dim, latent_dim, num_heads)(x)
8 encoder = keras.Model(encoder_inputs, encoder_outputs)
1 frames
[<ipython-input-9-23371d180913>](https://localhost:8080/#) in compute_mask(self, inputs, mask)
57
58 def compute_mask(self, inputs, mask=None):
---> 59 return tf.math.not_equal(inputs, 0)
60
61 def get_config(self):
ValueError: 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.
What you should do instead is wrap `tf_fn` in a layer:
class MyLayer(Layer):
def call(self, x):
return tf_fn(x)
x = MyLayer()(x)
Error thrown at
Stacktrace