Why is Units same as size of vocabulary for dense layer Doubt

Hello,

I don’t know if I understood this correctly or not, so wanted to confirm here

The dense layer with logsoftmax activation in the Decoder cell uses units as vocab_size, and the instructions mentions the reason as

Finally a 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.

So this is because number of hidden units are suppose to be equal to vocab size as per what I learnt from the video instructor for the translator to be able translate or decode the words?

is my understanding correct, if not please enlighten me.

Thank you in advance.

Regards
DP

3 Likes

Hi @Deepti_Prasad,

You mean this in unit in the translator: units (int): Number of units in the LSTM layer?

2 Likes

No the dense layer, that’s what the code mentioned, do you want me to share the code? I didn’t share as it was part of graded codes.

Thank you gent.

Regards
DP

2 Likes

The final dense layer has the same number of neurons as the vocab size from what i understand for the reasons you also mention!

4 Likes

It sounds reasonable to me too, that the output layer has the same size as vocab size so that it can predict the probabilities for each of the vocab.

4 Likes

That’s right what @rmwkwok said. I would like to make an amend to @Deepti_Prasad your comment about the Dense layer being the hidden units, but in fact it is the output layer of the Decoder.

4 Likes

So my reasoning of understanding is correct, thank you everyone :pray:t2:

Regards
DP

2 Likes