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
Any help on this issue is greatly appreciated. I have been following the source code for keras_nlp.layers.PositionEmbedding() (tutorial found here https://keras.io/api/keras_nlp/modeling_layers/position_embedding/), but I am coming across an error which I am having trouble debugging. The error reads,
TypeError: Exception encountered when calling PositionEmbedding.call().
Dimension value must be integer or None or have an index method, got value '<attribute 'shape' of 'numpy.generic' objects>' with type '<class 'getset_descriptor'>'
Arguments received by PositionEmbedding.call():
• inputs=tf.Tensor(shape=(None, 256, 128), dtype=float32)
• start_index=0
The code that triggers this error is below: inputs = layers.Input((config.MAX_LEN,), dtype="int64") word_embeddings = keras.layers.Embedding( config.VOCAB_SIZE, config.EMBED_DIM, name="word_embedding" )(inputs) position_embeddings = keras_nlp.layers.PositionEmbedding( sequence_length=config.MAX_LEN, )(word_embeddings) embeddings = word_embeddings + position_embeddings
config.MAX_LEN is an integer (I have checked its type), and the word_embeddings have shape (None, 256, 128), so I think they are getting created correctly?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
Any help on this issue is greatly appreciated. I have been following the source code for keras_nlp.layers.PositionEmbedding() (tutorial found here https://keras.io/api/keras_nlp/modeling_layers/position_embedding/), but I am coming across an error which I am having trouble debugging. The error reads,
TypeError: Exception encountered when calling PositionEmbedding.call().
Dimension value must be integer or None or have an index method, got value '<attribute 'shape' of 'numpy.generic' objects>' with type '<class 'getset_descriptor'>'
Arguments received by PositionEmbedding.call():
• inputs=tf.Tensor(shape=(None, 256, 128), dtype=float32)
• start_index=0
The code that triggers this error is below:
inputs = layers.Input((config.MAX_LEN,), dtype="int64") word_embeddings = keras.layers.Embedding( config.VOCAB_SIZE, config.EMBED_DIM, name="word_embedding" )(inputs) position_embeddings = keras_nlp.layers.PositionEmbedding( sequence_length=config.MAX_LEN, )(word_embeddings) embeddings = word_embeddings + position_embeddings
config.MAX_LEN is an integer (I have checked its type), and the word_embeddings have shape (None, 256, 128), so I think they are getting created correctly?
Again, any help is much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions