UNQ_C5 Wrong type. Output must be a tensor

I am having an issue with the Encoder class. I keep getting the error below, I have checked the type of x and it is an <class 'tensorflow.python.framework.ops.EagerTensor'> until it hits the for loop and then self.enc_layers returns a <class 'tensorflow.python.training.tracking.data_structures.ListWrapper'> Can anyone help ?

AssertionError                            Traceback (most recent call last)
<ipython-input-201-68aa9b8f5815> in <module>
      1 # UNIT TEST
----> 2 Encoder_test(Encoder)

~/work/W4A1/public_tests.py in Encoder_test(target)
    116     encoderq_output = encoderq(x, True, None)
    117 
--> 118     assert tf.is_tensor(encoderq_output), "Wrong type. Output must be a tensor"
    119     assert tuple(tf.shape(encoderq_output).numpy()) == (x.shape[0], x.shape[1], embedding_dim), f"Wrong shape. We expected ({x.shape[0]}, {x.shape[1]}, {embedding_dim})"
    120     assert np.allclose(encoderq_output.numpy(), 

AssertionError: Wrong type. Output must be a tensor

Solved this by calling the layers correctly !

2 Likes