How to acces label names from predictions

Hi,
if I have predictions on my validation set with:

preds = learn.get_preds()

then

torch.argmax(preds[0],dim=1)[:15]
>>> tensor([19, 19, 19, 19,  5,  5,  5, 27, 27, 27, 27, 27, 27, 27, 27])

How can I get back the category names from that? I want a list similar to this:

>>> ['DH', 'DH', 'DH', 'DH', 'AH0', 'AH0', 'AH0', 'HH', 'HH', 'HH', 'HH', 'HH', 'HH', 'HH', 'HH']

Is there a dictionary stored anywhere in the data block, where every number is assigned to a category?

is there anyone who could help me?

Learn.data.c2i is where it is stored. (Class 2 Index)

2 Likes

thank you very much!