If you have the same error output as the post creator, then the issue is the way you are recalling logits.
Remember.
remember (64,14) is the vocab_size and unit and 256 is a batch of sentences used to translate English to Portuguese.
So when the logits shape expected output is (64, 15, 12000)
12,000 is the size of the vocabulary since you expect it to compute the logits for every possible word in the vocabulary,
This mean vocab_size for context, right-sided translation and logits is same, so this is not issue with your codes
but units don’t match for contexts but do match for right-sighted translation as well as logits, so for the code line
The dense layer with logsoftmax activation in the class Decoder(tf.keras.layers.Layer):
requires you to recall units as vocab_size as it is mentioned before the grader cell for this dense layer: This one should have the same number of units as the size of the vocabulary since you expect it to compute the logits for every possible word in the vocabulary.
Thank you, I missed the fact that the logsoftmax function should be initiated with the vocab_size as opposed to with the units. Using the vocab_size makes a lot more sense though because the layer is calculating for the probability of each word in the vocab.
I noticed one small detail that I’d like to adjust (for future readers) - the Dense layer needs the vocab_size not the logsoftmax. The logsoftmax does not “care” about the output size (it just normalization).