C5_W4_A1_Transformer_Subclass_v1, Scale scale embeddings by multiplying by the square root of their dimension

Good Evening,

I am on the final project of the 5th Deep Learning Course. I am having issues with
Project: C5_W4_A1_Transformer_Subclass_v1
Grading Cell: # UNQ_C7 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)

GRADED FUNCTION Decoder

Portion: #scale embeddings by multiplying by the square root of their dimension

Specifically, I input: x *= tf.sqrt(tf.cast(self.embedding_dim, tf.float32))

and am getting the below error:

ValueError: Attempt to convert a value (<tensorflow.python.keras.layers.embeddings.Embedding object at 0x7f6cf45ae310>) with an unsupported type (<class ‘tensorflow.python.keras.layers.embeddings.Embedding’>) to a Tensor.

I’ve looked all over the forum and can’t seem to see why the error is occurring but I am using the same coding everyone else on the forum seems to. Any help is appreciated. I’ve uploaded full screen shots of the error below.





Hi @Lazz0402 ,

It looks like you did not create word embeddings correctly, please check the line below. You can refer to Encoder in UNQ_C5, they do the same thing.
image

1 Like

Thank you very much. I made a silly error where I failed to reference the input x in the self.embedding function.

Everything works fine now.

1 Like