more docs

This commit is contained in:
CarloLucibello 2020-04-30 12:26:58 +02:00
parent b44ba162b1
commit 79391beca0
1 changed files with 13 additions and 2 deletions

View File

@ -1,12 +1,23 @@
## Loss Functions
Flux provides a large number of common loss functions used for training machine learning models.
Loss functions for supervised learning typically expect as inputs a target `y`, and a prediction `ŷ`.
In Flux's convention, the order of the arguments is the following
```julia
loss(ŷ, y)
```
Most loss functions in Flux have an optional argument `agg`, denoting the type of aggregation performed over the
batch:
```julia
loss(ŷ, y; agg=mean)
loss(ŷ, y) # defaults to `mean`
loss(ŷ, y, agg=sum) # use `sum` for reduction
loss(ŷ, y, agg=x->sum(x, dims=2)) # partial reduction
loss(ŷ, y, agg=x->mean(w .* x)) # weighted mean
loss(ŷ, y, agg=identity) # no aggregation.
```
### Losses Reference
```@docs
Flux.mae
Flux.mse
@ -22,4 +33,4 @@ Flux.hinge
Flux.squared_hinge
Flux.dice_coeff_loss
Flux.tversky_loss
```
```