def postprocessor ( prediction ) : prediction = prediction . data . numpy ( ) [ 0 ] top_predictions = prediction . argsort ( ) [ - 3 : ] [ : : - 1 ] return [ labels [ prediction ] for prediction in top_predictions ]
get label wise top words python
Map prediction tensor to labels .
def postprocessor(prediction):
    """Map prediction tensor to labels."""
    prediction = prediction.data.numpy()[0]
    top_predictions = prediction.argsort()[-3:][::-1]
    return [labels[prediction] for prediction in top_predictions]