[week 4] Transformer Network - get_angles

Hello, Have you solve the problem? I’m getting same error.

Hello,
Can anyone help me find out what is wrong with my code?

# START CODE HERE
  # mentor edit: code removed
# END CODE HERE"

Getting error: “AssertionError: Wrong shape. We expected: (1, 8, 16)”

Hi @fjsarmin ,

Your code looks fine. However, but I don’t know how your get_angles() works. One way to debug is to print out the pos_encoding.shape to help locate the problem.

Thank you for the information.
After tried for few hours, it has been solved.

Great to hear the problem is solved. Thanks

Good afternoon. When you solved the problem with C5_W4 UNQ_C2, did the issue end up being with the first cell?

Chris

My apology for being late.
Yes, the issue end up being with the first cell.

and the vector_dimention what should be ?
thanks

The latest update of the notebook now does not have it implemented already

I think there is a typo in Eq (3). The i on LHS is not the same thing as the i on RHS. It’s better to replace the i on LHS with k, which is used in the section.

If we don’t want to introduce k in the equation, RHS should be modified to contain the the correct expression using the floor function notation (\lfloor x \rfloor). The RHS should be \theta(pos, i, d) = \frac{pos}{1000^{2 \lfloor i/2 \rfloor / d}}.

BTW, this is exactly what the get_angles function does.

Similarly, in the Exercise 2 section, it should say “Use the sine equation when k is an even number and cosine equation when k is an odd number.”

Thanks.

Hi,
I am getting the same problem with the shape


Please let me know where did i go wrong

Your shape is wrong because you may mistake to declare the correct argument pos_m, k, and d has already been given. Hint: take a look at how those arguments correctly define in the previous get_angles_test() and use those analogies.

1 Like

Thank you, that works

Equation 3 in the lab is confusing. The expression (2i/d) does not look like exponentiation in the lab’s formatting, and I honestly thought it was multiplied by 10000 instead. I only figured it out by looking at the forums here. I passed the problem no problem after making the fix, but I’m surprised that everyone else on these posts seemed to have correctly recognized that the term was an exponent.

4 Likes


I use your formula.But it’s still wrong?I’m confused.

thank you thank you thank you

OMG your comment helped me a lot. I was banging my head try to figure out how not to divide by zero. Thanks