Skip to content

Commit e0d3d8b

Browse files
committed
better words
1 parent c7ed3fd commit e0d3d8b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/compiler/interface.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ julia> ∇ == gradient(/, 1, 2)
119119
true
120120
```
121121
122-
If `f` returns a Tuple or NamedTuple, then it calculates
123-
`gradient(first∘f, args...)` but returns the whole `f(args...)`:
122+
Allows you to capture auxillary outputs, in addition to the scalar
123+
used by `gradient`. To do this, `f` must return a Tuple or NamedTuple.
124+
Then it calculates `grad = gradient(first∘f, args...)
125+
but returns the whole `val = f(args...)`:
124126
125127
```jldoctest; setup=:(using Zygote)
126128
julia> withgradient([1,2,4]) do x
127129
z = 1 ./ x
128-
sum(z), z
130+
sum(z), z # here z is an auxillary output
129131
end
130132
(val = (1.75, [1.0, 0.5, 0.25]), grad = ([-1.0, -0.25, -0.0625],))
131133

0 commit comments

Comments
 (0)