Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Oct 18, 2022
1 parent 8917099 commit 39055ae
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docs/src/models/losses.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ In Flux's convention, the target is the last argumemt:
loss(ŷ, y)
```

All loss functions have a method which takes the model as the first argument, and calculates the prediction `ŷ = model(x)`.
All loss functions in Flux have a method which takes the model as the first argument, and calculates the prediction `ŷ = model(x)`.
This is convenient for [`train!`](@ref Flux.train)`(loss, model, [(x,y), (x2,y2), ...], opt)`:

```julia
loss(model, x, y) = loss(model(x), y)
```

Most loss functions in Flux have an optional argument `agg`, denoting the type of aggregation performed over the
batch:
Most loss functions in Flux have an optional keyword argument `agg`, which is the aggregation function used over the batch:

```julia
loss(ŷ, y) # defaults to `mean`
loss(ŷ, y, agg=sum) # use `sum` instead
loss(ŷ, y, agg=x->mean(w .* x)) # weighted mean
loss(ŷ, y, agg=x->sum(x, dims=2)) # partial reduction, returns an array
loss(ŷ, y) # defaults to `Statistics.mean`
loss(ŷ, y; agg = sum) # use `sum` instead
loss(ŷ, y; agg = x->mean(w .* x)) # weighted mean
loss(ŷ, y; agg = x->sum(x, dims=2)) # partial reduction, returns an array
```

### Function listing
Expand Down

0 comments on commit 39055ae

Please sign in to comment.