PyTorch implementation of POLYLOSS: A POLYNOMIAL EXPANSION PERSPECTIVE OF CLASSIFICATION LOSS FUNCTIONS
polyloss.py contains the implementation of Poly-1 loss and Poly-1 focal loss.
While polynloss.py contains simple implementations of Poly-N and Poly-N focal loss. Note that this implemenation of Poly-N loss is just for experimenation.
Simple_Example_Polyloss.ipynb is notebook with simple examples of Poly-1 loss usage.
- Git clone the repoository and change to directory
git clone https://github.com/nachiket273/loss-tryout.git
cd loss-tryout
- Import
from polyloss import PolyLoss, PolyFocalLoss
- Poly crossentropy loss example
import torch
inputs = torch.rand((20, 5))
targets = torch.randint(high=5, size=(20,))
ploss = PolyLoss()
ploss(inputs, targets)
- Poly focal loss example
import torch
inputs = torch.rand((20, 5))
targets = torch.randint(high=5, size=(20,))
pfloss = PolyFocalLoss()
pfloss(inputs, targets)
@misc{POLYLOSS,
title={POLYLOSS: A POLYNOMIAL EXPANSION PERSPECTIVE OF CLASSIFICATION LOSS FUNCTIONS},
author={Zhaoqi Leng, Mingxing Tan, Chenxi Liu, Ekin Dogus Cubuk, Xiaojie Shi, Shuyang Cheng, Dragomir Anguelov},
year={2022},
url={https://arxiv.org/pdf/2204.12511.pdf},
}