I would like to adapt the code of PTB Tensorflow code [https://github.com/tensorflow/models/blob/master/tutorials/rnn/ptb/ptb_word_lm.py], in order to calculate top k predicted word samples, on the basis of given input word sequence? I am confused in the answer mentioned here [How Tensorflow text prediction predicts without softmax activation.

Following can be the options:

Option 1: We can use tf.multinomial, which is similar to tf.random.categorical

self.predictions = tf.multinomial(logits, k)

Option 2: The other option can be to call a specific function, which will output the value coming from the following line, in k number of times.


Which option will give me fair experimental results?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.