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:
- Add
nn/loss/l1.v — Mean Absolute Error (L1 loss)
- Add
nn/loss/hinge.v — Hinge loss for binary SVM-style training
- Add
nn/loss/focal.v — Focal loss for imbalanced classification
- 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)
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.vandnn/loss/huber.v:nn/loss/l1.v— Mean Absolute Error (L1 loss)nn/loss/hinge.v— Hinge loss for binary SVM-style trainingnn/loss/focal.v— Focal loss for imbalanced classificationnn/loss/loss_test.vVerification