C5_W4_A1_Transformer_Subclass_v1 - UNQ_C4

Hi, I am getting this AttributeError and I don’t know how to proceed. Does this have to do with eager mode in TF?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-44-00617004b1af> in <module>
      1 # UNIT TEST
----> 2 EncoderLayer_test(EncoderLayer)

~/work/W4A1/public_tests.py in EncoderLayer_test(target)
     87 
     88     assert tf.is_tensor(encoded), "Wrong type. Output must be a tensor"
---> 89     assert tuple(tf.shape(encoded).numpy()) == (1, q.shape[1], q.shape[2]), f"Wrong shape. We expected ((1, {q.shape[1]}, {q.shape[2]}))"
     90 
     91     assert np.allclose(encoded.numpy(), 

AttributeError: 'KerasTensor' object has no attribute 'numpy'

Thank you!

Hi @Orfeas_Kypris,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

Thanks,
Mubsi

Hi Mubsi,

Thanks so much for your prompt reply and your help. My lab id is phqjewkh.

Thanks,
O

Hi @Orfeas_Kypris,

My apologise for replying this late, I got busy.
Is this something I can still help you out with ? Or anything else ?

Regards,
Mubsi

Hi @Mubsi , I would still need your help with this as I have not made any progress as of yet. Thanks!

I tried once again to fix the error, even tried upgrading the notebook version, but the error still persists.

Hi @Orfeas_Kypris, can you share your lab ID with me ? Thanks.

Hi @Mubsi , it is phqjewkh

HI @Orfeas_Kypris,

I took a look at your notebook, and in Ex 4, your implementation of the variables attn_output and encoder_layer_out was incorrect. You were not passing the right input values in attn_output, and your addition was wrong in encoder_layer_out. Details have been left in your notebook.

Happy learning,
Mubsi

Thank you so much @Mubsi ! I will have a look at it.