> For the complete documentation index, see [llms.txt](https://hypergan.gitbook.io/hypergan/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hypergan.gitbook.io/hypergan/components/loss/qp-loss.md).

# QP Loss

* From <https://arxiv.org/abs/1811.07296>
* Source: [/losses/qp\_loss\_loss.py](https://github.com/HyperGAN/HyperGAN/tree/pytorch/hypergan/losses/qp_loss_loss.py)

```python
lam = 10.0/(reduce(lambda x,y:x*y, gan.output_shape()))
dist = (gan.generator.sample - self.gan.inputs.sample).abs().mean()

dl = - d_real + d_fake
d_norm = 10 * dist
d_loss = ( dl + 0.5 * dl**2 / d_norm).mean()

g_loss = d_real - d_fake
```

## examples

```javascript
{                                                                                       
  "class": "function:hypergan.losses.qp_loss.QPLoss"
}
```
