Inference step buggy when using MixUp trained learner with predict

Hi there,
I have recently started using the library and really enjoy it thus far!
However, I have come across a problem with MixUp at inference time, where when trying to predict the image label for a sports classification task, the prediction does not get decoded properly. So the code I am trying to run is:

mixup = MixUp()
learn_mixup = cnn_learner(dls, resnet18, metrics=error_rate,

learn_mixup.fit_one_cycle(1, 3e-3)


However, instead of getting an output from predict like

('table_tennis', TensorImage(1), TensorImage([ 2.5575,  0.4804, -1.2981,  2.2679, -1.4216]]))

(when not using MixUp during training) , I receive the following output(s) (for a single image):

("['motogp', 'badminton', 'tennis', 'motogp', 'tennis']", TensorImage([ 2.5575,  0.4804, -1.2981,  2.2679, -1.4216]), TensorImage([ 2.5575,  0.4804, -1.2981,  2.2679, -1.4216]))

I have tracked this problem a bit further and the issue seems to arise in when the self.loss_func loses its decodes function when entering the with ContextManagers(ctx_mgrs): scope. This does not happen when not using MixUp. As self.loss_func.decodes becomes a noop function, we fail to decode the TensorImage([ 2.5575, 0.4804, -1.2981, 2.2679, -1.4216]) to become a TensorImage(1) , and instead later on just convert those loss terms individually to categories to get the predictions ['motogp', 'badminton', 'tennis', 'motogp', 'tennis'] for the single image.
I am a bit at a loss what happens inside with ContextManagers(ctx_mgrs): that makes our self.loss_func lose its decodes member function. So I’d appreciate any advice or help :slight_smile:
Thanks in advance!

This is quite old but just thought I’d let you know that this is no longer an issue. :slight_smile:

@muellerzr ah cool, good to hear! Thanks for letting me know :slight_smile: