Thanks for quoting my previous answer.
In this case, if you use the shadoworflow backend, I suggest you use this shadoworflow function:
tf.nn.in_top_k( predictions, targets, k, name=None )
It outputs the tensor bools, 1 if the answer belongs to the vertex k and 0 if not.
If you need more information, I linked the documentation with tensor flow. I hope this helps. :-)
source share