How to achieve this function in pytorch?
tf.math.in_top_k(
targets, predictions, k, name=None
)
How to achieve this function in pytorch?
tf.math.in_top_k(
targets, predictions, k, name=None
)
Try something similar.
top_k = torch.topk(targets, k)
if any([(targets == c_).all() for c_ in predictions]):
print('targets in top_k predictions')