C5 week 4 Transformer Encoder incompatible shapes

When running test for UNQ_C5, I get the following error:
InvalidArgumentError: Incompatible shapes: [2,3,4] vs. [1,3,10] [Op:AddV2]
running these two lines:
print(tf.shape(self.pos_encoding)) # result tf.Tensor([ 1 5 10], shape=(3,), dtype=int32)
print(tf.shape(x)) # tf.Tensor([2 3 4], shape=(3,), dtype=int32)

It turns out they cannot be added, the dimensions are not compatible at all.

It looks like self.pos_encoding has a problem. Do you pass UNQ_C2? If you passed UNQ_C2 and didn’t change any unit test code, it should not happen. Could you check it? Please let me know if it’s not the case.

@edwardyu Thank you for the answer
I solved it, the problem was indeed in C2, it passed the test but wasn’t implemented correctly I changed the implementation and it worked fine.

Do you know how to download the notebook workspace? when there are data files that are bigger than 100MB like h5 files they cannot be split and I can’t download all the notebook workspace.

I used to download the whole folders by following steps:

  1. tar (with compress flag) all files together.
  2. split the tar file into small size, e.g., 50m.
  3. download and merge them back, or just use some tools like 7z to open the first split files.
  4. remove all tar file and split files (to avoid exhausting server disk capacity.)
1 Like

Hi @Sofiane, Can you please suggest me what changes you did in C2. I did passed the test case in C2. And I am facing below error:
InvalidArgumentError: Incompatible shapes: [1,4,3,3] vs. [1,1,1,5] [Op:AddV2]

angle_rads = get_angles(np.arange(positions)[np.newaxis, …].T,
np.arange(d)[np.newaxis, …],
d)

2 Likes