# Loss Functions

- [X] Cross Entropy Error (Binary Cross Entropy)
- [X] Earth Mover Distance
- [x] Hinge Embedding Loss
- [X] Huber Loss / Smooth L1 Loss
- [X] KL Divergence Loss
- [X] L1 Loss
- [X] Log CosH Loss
- [X] Mean Bias Error
- [X] Mean Squared Error
- [X] Mean Squared Logarithmic Error
- [X] NLL Loss
- [ ] Margin Ranking Loss (can't be done without major modifications, see notebook)
- [ ] Cosine Embedding Loss (```kartikdutt18``` said he will be doing this)

## Linked Issue

[#2444](https://github.com/mlpack/mlpack/issues/2444)

## Linked PR

[#2495](https://github.com/mlpack/mlpack/pull/2495)

## Link to Blogs

- [Blog post 1](https://iamshnoo.github.io/blog/week-2/)
- [Blog post 2](https://iamshnoo.github.io/blog/week-3/)

## What this folder contains

Jupyter Notebooks comparing PyTorch/numpy implementations of each of the above
loss functions with mlpack/armadillo implementations along with explanations for
the possible errors in the existing implementations.

## How to run

To run the notebooks, you would need pytorch,
numpy and armadillo. To avoid issues with linking the libraries correctly, it is
better to run the notebook in Google Colab.

## Google Colab links for notebooks

- [Cross Entropy Error](https://colab.research.google.com/drive/14PxGHVCzNLa9mN4VGluM2p0oQ9OCpCMt?usp=sharing)
- [Earth Mover Distance](https://colab.research.google.com/drive/1xClRmLvuMMcVx5bXatWHJMEgmwR1SRbC?usp=sharing)
- [Hinge Embedding Loss](https://colab.research.google.com/drive/1umN57r7_b9wua4_Tz4OArIQthxSnDBIh?usp=sharing)
- [Huber Loss](https://colab.research.google.com/drive/1GxrvluR1aniIlM6d-O0Fq4NubY7uSB3E?usp=sharing)
- [KL Div Loss](https://colab.research.google.com/drive/1_57-NMliSNG3xtS3VNy1pXDqHYsHTYHn?usp=sharing)
- [L1 Loss](https://colab.research.google.com/drive/1EqxCl8jTw7vuWm-0WI_64e64MR6PUzSP?usp=sharing)
- [Log CosH Loss](https://colab.research.google.com/drive/1EQhfFZdhYxkcfkScDqcn8lYsWA0EtfzF?usp=sharing)
- [Margin Ranking Loss](https://colab.research.google.com/drive/1V-g_NmKMuM2EAm79CDwwAXswca1WbE0u?usp=sharing)
- [Mean Bias Error](https://colab.research.google.com/drive/1x8dGBxFl-XtwgPs4EU0-1fnuvLFOp1Xy?usp=sharing)
- [MSE Logarithmic](https://colab.research.google.com/drive/1d9qMrAh8_WdtR7d7L8hpe7MZK4qY3Dmr?usp=sharing)
- [MSE Loss](https://colab.research.google.com/drive/1TBWtFQa1Vxxpd_8GYocTZLGAopGJlfMp?usp=sharing)
- [NLL Loss](https://colab.research.google.com/drive/1_wUfSHE_c4ZsS1dPc5Q4iMhxdXqy_36N?usp=sharing)
