Skip to content

feat: add L1/MAE, Hinge, and Focal losses #153

Description

@ulises-jeremias

Only MSE, BCE, CrossEntropy, Huber, KL, NLL, SigmoidCE, and SoftmaxCE exist.
Add three widely used loss functions.

Task

Following the pattern of nn/loss/mse.v and nn/loss/huber.v:

  1. Add nn/loss/l1.v — Mean Absolute Error (L1 loss)
  2. Add nn/loss/hinge.v — Hinge loss for binary SVM-style training
  3. Add nn/loss/focal.v — Focal loss for imbalanced classification
  4. Add cases to nn/loss/loss_test.v

Verification

  • Loss values match PyTorch for same inputs
  • Backward gradients are correct (test with gradcheck if available)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions