Help with transformer notebook in deeo learning C5_W_4 EXERCISE #5

I need coding help with deep learning C5_W4 notebook - Transformers
persistent error in Exercise #5 (Creating Encoder) - error as noted below

I cannot see why my output -‘x’ is not a tensor here. All prior modules have been passed. The output x appears to have all the proper (tensor) dimensions (there is no point in the start coding at which the shape is explicitly set or changed, and the output x is being passed through layers which appear to be tensors

Any help would be appreciated.

AssertionError Traceback (most recent call last)
----> 2 Encoder_test(Encoder)

~/work/W4A1/ in Encoder_test(target)
116 encoderq_output = encoderq(x, True, None)
→ 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

Anytime I get a type error, my first step is to figure out what the wrong type is. That’s usually at least a clue as to the nature of the error.

I’ve moved your thread to the correct forum area (Deep Learning Specialization->Sequence Models->Week 4).

This indicates the issue is in your Encoder() class, since the test it is failing is the first time that class has been tested.