Flux.jl/docs/src/models/losses.md

1013 B

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

loss(, y)

Most loss functions in Flux have an optional argument agg, denoting the type of aggregation performed over the batch:

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

Flux.mae
Flux.mse
Flux.msle
Flux.huber_loss
Flux.crossentropy
Flux.logitcrossentropy
Flux.binarycrossentropy
Flux.logitbinarycrossentropy
Flux.kldivergence
Flux.poisson_loss
Flux.hinge
Flux.squared_hinge
Flux.dice_coeff_loss
Flux.tversky_loss