i am getting error : Incompatible shapes: [2,3,4] vs. [1,5,4] [Op:AddV2]) in #UNQ_C5
x giving output of shape (2, 3, 4) because Encoder_test passing (2,3) array as input and embedding_dim=4
but self.pos_encoding returning output of shape (1, 5, 4) as it is called with maximum_position_encoding=5 and embedding_dim=4 (from Encoder_test )
because the shapes of x and pos_encoding are different I am getting an Incompatible shapes error at step # Add the position encoding to embedding
UNQ_C2 is passed all tests but getting above error. Please suggest what am i am doing wrong here.
Had the same problem.
What I did was to add the mask according to the x’s dimension. For your case I add mask[0, :x.shape[1], : ]
Don’t know if it’s correct, but it passed the test
I had this error and was able to fix it, take a look at “add the position encoding to embedding”, and make sure you’re selecting the right part of of the position encoding. Once I fixed this one line it ran correctly.
I had the same error, and the problem was in UNQ_C2. Don’t know how I passed the unit tests for UNQ_C2. It seems like there should be an update to the unit test conditions.
My mistake was - I was calling get_angles() with the wrong parameters. Once I fixed that, the error was solved.
self.pos_encoding is computed using maximum_position_encoding. But the input passed to the function call does not necessarily reach the maximum number of positions. For example, the test code only has 3 positions but uses 5 as the maximum value. This can be solved by slicing the right part of self.pos_encoding in the code.
The instruction said to include [:, :seq_len, :], although it would’ve been more clear if the text was formatted as self.pos_encoding[:, :seq_len, :] instead.