# C5_W4_A1_Transformer_Subclass_v1 problem

Exercise 8 0/100
Cell #13. Can’t compile the student’s code. Error: AssertionError(‘Wrong masked weights’)

Here is my code.

``````# UNQ_C3 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)

{mentor edit: code removed - not allowed by the course Honor Code}
``````

When i run the code below,

# UNIT TEST

scaled_dot_product_attention_test(scaled_dot_product_attention)

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
----> 2 scaled_dot_product_attention_test(scaled_dot_product_attention)

~/work/W4A1/public_tests.py in scaled_dot_product_attention_test(target)
73 assert np.allclose(weights, [[0.30719590187072754, 0.5064803957939148, 0.0, 0.18632373213768005],
74 [0.3836517333984375, 0.3836517333984375, 0.0, 0.2326965481042862],
—> 75 [0.3836517333984375, 0.3836517333984375, 0.0, 0.2326965481042862]]), “Wrong masked weights”
76 assert np.allclose(attention, [[0.6928040981292725, 0.18632373213768005],
77 [0.6163482666015625, 0.2326965481042862],

There are no other mistakes in the homework in Exercise 8.

1 Like

Your code for applying the mask is not correct. You’ve missed subtracting it from 1. Read the instructions carefully.

1 Like

Sorry , but I tried many times , such as

"if mask is not None: # Don’t replace this None
{mentor edit: code removed}
"if mask is not None: # Don’t replace this None
{mentor edit: code removed}
or delete these code , the result never changes.

1 Like

set
{mentor edit: code removed}
can solve the problem.

2 Likes