C4W1: Exercise 4 - Translator

Hi, I’ve been having this error with the class Translator,

InvalidArgumentError: Exception encountered when calling layer ‘key’ (type EinsumDense).

cannot compute Einsum as input #1(zero-based) was expected to be a int64 tensor but is a float tensor [Op:Einsum] name:

Call arguments received by layer ‘key’ (type EinsumDense):
inputs=tf.Tensor(shape=(64, 18), dtype=int64)

Here is the full error:

I tried casting the context and target to float32 but it just lead to more errors. All the previous test were passed, so I’m not really sure what to do here

Thank you in advance

At logits = the comment tells you to use the encoded context!

Compute the logits by passing the encoded context and the target to the decoder

Also if this doesnt work out check your implementation self.mha at the CrossAttention class!

Thank you! I changed it to encoded_context and it works

1 Like