seq_len = tf.shape(x)[1]
# START CODE HERE
x = self.embedding(x)
x *= tf.math.sqrt(tf.cast(self.embedding_dim, tf.float32))
x += self.pos_encoding[:, :seq_len, :]
x = self.dropout(x, training=training)
for i in range(self.num_layers):
self.enc_layers[i](x, training, mask)
I don’t know where I did wrong with my code ;( can someone help me?
Maybe try tf.sqrt instead of tf.math.sqrt I don’t think it should make a difference though? Maybe also try saving and clearing the kernel and running everything over again? You could try adding a print to the assertion that’s failing and comparing the results you have with the expected ones, sometimes that helps.
@Anomy, @ccc888 I checked previous codes and everything works fine…
this is my previous code for encoder layer, which also passes the test…
do you think there’s anything wrong with this code?
Sorry, my subscription ended yesterday so I don’t have access to the assignment anymore to look at the context. Have you tried labeling the parameters for mha?