@@ -10,21 +10,20 @@ In Flux's convention, the target is the last argumemt:
10
10
loss (ŷ, y)
11
11
```
12
12
13
- All loss functions have a method which takes the model as the first argument, and calculates the prediction ` ŷ = model(x) ` .
13
+ All loss functions in Flux have a method which takes the model as the first argument, and calculates the prediction ` ŷ = model(x) ` .
14
14
This is convenient for [ ` train! ` ] (@ref Flux.train)` (loss, model, [(x,y), (x2,y2), ...], opt) ` :
15
15
16
16
``` julia
17
17
loss (model, x, y) = loss (model (x), y)
18
18
```
19
19
20
- Most loss functions in Flux have an optional argument ` agg ` , denoting the type of aggregation performed over the
21
- batch:
20
+ Most loss functions in Flux have an optional keyword argument ` agg ` , which is the aggregation function used over the batch:
22
21
23
22
``` julia
24
- loss (ŷ, y) # defaults to `mean`
25
- loss (ŷ, y, agg= sum) # use `sum` instead
26
- loss (ŷ, y, agg= x-> mean (w .* x)) # weighted mean
27
- loss (ŷ, y, agg= x-> sum (x, dims= 2 )) # partial reduction, returns an array
23
+ loss (ŷ, y) # defaults to `Statistics. mean`
24
+ loss (ŷ, y; agg = sum) # use `sum` instead
25
+ loss (ŷ, y; agg = x-> mean (w .* x)) # weighted mean
26
+ loss (ŷ, y; agg = x-> sum (x, dims= 2 )) # partial reduction, returns an array
28
27
```
29
28
30
29
### Function listing
0 commit comments