Feature request: easier interpretation of get_preds()

Hi guys and gals, can I ask for your opinion on this idea?

Is your feature request related to a problem? Please describe.
I always have difficulties when I use learn.get_preds() because I can’t remember in which order the elements of the returned tuple are. Especially when you add the optional parameters:

a,b,c,d,e = learn.get_preds(with_inputs=True, with_decoded=True, with_loss=True)

Describe the solution you’d like
Could we return a namedtuple instead? This would make it very easy to see what each item of the tuple stands for while maintaining backward compatibility.
Instead of this:

learn.get_preds(with_input=True, with_loss=True)
>>> ('TensorImage(...)', [0.1,0.9], 1, 0.4)

we return this:

>>> Predictions(input='TensorImage(...)', predictions=[0.1,0.9], target=1, loss=0.4)

I think this would be in line with fastai’s philosophy of self-documenting functionality.

Describe alternatives you’ve considered
Alternatively, we could add the order of the tuple to the documentation.

1 Like