I've been faced with an error in the PositionalEmbedding step on the original notebook
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start with the PositionalEmbedding class and the notebook cell that calls embed_pt(pt), then reproduce the reported error using the shown tensor shape and dtype. Done means the original notebook's PositionalEmbedding step runs without the Invalid dtype error.
Written by the indexing model from the issue text.
Description
class PositionalEmbedding(tf.keras.layers.Layer):
def __init__(self, vocab_size, d_model):
super().__init__()
self.d_model = d_model
self.embedding = tf.keras.layers.Embedding(vocab_size, d_model, mask_zero=True)
self.pos_encoding = positional_encoding(length=2048, depth=d_model)
def compute_mask(self, *args, **kwargs):
return self.embedding.compute_mask(*args, **kwargs)
def call(self, x):
length = tf.shape(x)[1]
x = self.embedding(x)
# This factor sets the relative scale of the embedding and positonal_encoding.
x *= tf.math.sqrt(tf.cast(self.d_model, tf.float32))
x = x + self.pos_encoding[tf.newaxis, :length, :]
return x
embed_pt = PositionalEmbedding(vocab_size=tokenizers.pt.get_vocab_size(), d_model=512)
pt_emb = embed_pt(pt)
Error Log:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[<ipython-input-79-19249302cd7f>](https://localhost:8080/#) in <cell line: 1>()
----> 1 pt_emb = embed_pt(pt)
2 en_emb = embed_en(en)
1 frames
[/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py](https://localhost:8080/#) in error_handler(*args, **kwargs)
120 # To get the full stack trace, call:
121 # `keras.config.disable_traceback_filtering()`
--> 122 raise e.with_traceback(filtered_tb) from None
123 finally:
124 del filtered_tb
[<ipython-input-77-e9ab4e283481>](https://localhost:8080/#) in call(self, x)
11 def call(self, x):
12 length = tf.shape(x)[1]
---> 13 x = self.embedding(x)
14 # This factor sets the relative scale of the embedding and positonal_encoding.
15 x *= tf.math.sqrt(tf.cast(self.d_model, tf.float32))
ValueError: Exception encountered when calling PositionalEmbedding.call().
Invalid dtype: <property object at 0x7e5961d38810>
Arguments received by PositionalEmbedding.call():
• x=tf.Tensor(shape=(64, 92), dtype=int64)
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 379
- Avg merge
- 7h 46m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tensorflow/text
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
tensorflow/text#1498 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tensorflow/text#1497 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
tensorflow/text#1448 · 3 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tensorflow/text#1421 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
tensorflow/text#1393 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
area/ysql kind/bug priority/medium
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yugabyte/yugabyte-db#34552 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 94/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
ai_p2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/ClickHouse#123351 ·
Maintainers usually reply within 1 day