Debugging C5 W4 Ex3

I have some bug found in unit testing:
60 assert np.allclose(weights, [[0.2589478, 0.42693272, 0.15705977, 0.15705977],
61 [0.2772748, 0.2772748, 0.2772748, 0.16817567],
—> 62 [0.33620113, 0.33620113, 0.12368149, 0.2039163 ]])
63
64 assert tf.is_tensor(attention), “Output must be a tensor”

AssertionError:

Not sure what’s wrong with my code:

def scaled_dot_product_attention(q, k, v, mask):

# START CODE HERE

# mentor edit: code removed

# END CODE HERE

return output, attention_weights
1 Like

There are several problems.

  1. Don’t post your code on the Forums. That breaks the Honor Code.
  2. “dk” should not be set to a constant value.
  3. Use tf.sqrt() instead of np.sqrt()
  4. Read the instructions carefully for how to use the “mask” value.
  5. Don’t use an axis argument on the softmax activation.
1 Like