TypeError: no implementation found for 'torch.nn.functional.smooth_l1_loss' on types that implement __torch_function__: [<class 'fastai.torch_core.TensorImage'>, <class 'fastai.vision.core.TensorBBox'>]

I am trying to use the fastai library to build a machine learning model for object detection. I’m not an expert in machine learning, so I searched online and found this tutorial at object detection tutorial but when I used Google colab to run it, I got error saying: TypeError: no implementation found for ‘torch.nn.functional.smooth_l1_loss’ on types that implement torch_function : [<class ‘fastai.torch_core.TensorImage’>, <class ‘fastai.vision.core.TensorBBox’>] And I’ve also tried a 2018 version of the same tutorial before but ran into the same problem. Does anyone know what’s going on?

1 Like

I had to do this to get it working:

TensorImage.register_func(torch.nn.functional.smooth_l1_loss, TensorImage, TensorBBox)
TensorMultiCategory.register_func(TensorMultiCategory.mul, TensorMultiCategory, TensorImage)
TensorImage.register_func(torch.nn.functional.binary_cross_entropy_with_logits, TensorImage, TensorMultiCategory)

There is an issue currently because of named tensors as of pytorch 1.8(ish?)

1 Like

This seems to have fixed the problem! Thank you so much!

1 Like

Thanks. I had same issue!

1 Like