ML Katas

Implement a Custom Loss Function

medium (<30 mins) pytorch loss functions regression implementation
this month by E

Create a custom loss function called MeanAbsolutePercentageError (MAPE) in PyTorch. It should:

  1. Take predictions and targets as input tensors.
  2. Compute 1ni|yiy^i||yi|+ϵ, with ϵ=1e8 to avoid division by zero.
  3. Return a scalar tensor.

Test it on a random regression output.