Skip to content

Commit 15c8590

Browse files
authored
Fix a few crossrefs + update Zygote's page (#2064)
* Fix a few crossrefs + update Zygote's page * Sync with recent changes * Fix docs for default_rng_value
1 parent dfd4549 commit 15c8590

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

docs/src/training/zygote.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
# Automatic Differentiation using Zygote.jl
22

3-
Flux re-exports the `gradient` from [Zygote](https://github.com/FluxML/Zygote.jl), and uses this function within [`train!`](@ref) to differentiate the model. Zygote has its own [documentation](https://fluxml.ai/Zygote.jl/dev/), in particular listing some [important limitations](https://fluxml.ai/Zygote.jl/dev/limitations/).
3+
Flux re-exports the `gradient` from [Zygote](https://github.com/FluxML/Zygote.jl), and uses this function within [`train!`](@ref Flux.train!) to differentiate the model. Zygote has its own [documentation](https://fluxml.ai/Zygote.jl/dev/), in particular listing some [important limitations](https://fluxml.ai/Zygote.jl/dev/limitations/).
44

5-
### Implicit style
5+
## Implicit style
66

77
Flux uses primarily what Zygote calls "implicit" gradients, [described here](https://fluxml.ai/Zygote.jl/dev/#Explicit-and-Implicit-Parameters-1) in its documentation.
88

99
```@docs
1010
Zygote.gradient
1111
Zygote.Params
1212
Zygote.Grads
13+
Zygote.jacobian(loss, ::Params)
1314
```
1415

15-
### Explicit style
16+
## Explicit style
1617

1718
The other way of using Zygote, and using most other AD packages, is to explicitly provide a function and its arguments.
1819

1920
```@docs
2021
Zygote.gradient(f, args...)
2122
Zygote.withgradient(f, args...)
2223
Zygote.jacobian(f, args...)
24+
Zygote.withgradient
2325
```
2426

2527

26-
### ChainRules
28+
## ChainRules
2729

2830
Sometimes it is necessary to exclude some code, or a whole function, from automatic differentiation. This can be done using [ChainRules](https://github.com/JuliaDiff/ChainRules.jl):
2931

@@ -36,4 +38,4 @@ To manually supply the gradient for one function, you should define a method of
3638

3739
```@docs
3840
ChainRulesCore.rrule
39-
```
41+
```

src/losses/functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ Return the binary cross-entropy loss, computed as
273273
274274
agg(@.(-y * log(ŷ + ϵ) - (1 - y) * log(1 - ŷ + ϵ)))
275275
276-
Where typically, the prediction `ŷ` is given by the output of a [sigmoid](@ref Activation-Functions) activation.
276+
Where typically, the prediction `ŷ` is given by the output of a [sigmoid](@ref Activation-Functions-from-NNlib.jl) activation.
277277
The `ϵ` term is included to avoid infinity. Using [`logitbinarycrossentropy`](@ref) is recomended
278278
over `binarycrossentropy` for numerical stability.
279279

src/utils.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,20 @@ rng_from_array(::CuArray) = CUDA.default_rng()
4949
@non_differentiable rng_from_array(::Any)
5050

5151
if VERSION >= v"1.7"
52-
@doc """
53-
default_rng_value()
54-
55-
Create an instance of the default RNG depending on Julia's version.
56-
- Julia version is < 1.7: `Random.GLOBAL_RNG`
57-
- Julia version is >= 1.7: `Random.default_rng()`
58-
"""
5952
default_rng_value() = Random.default_rng()
6053
else
6154
default_rng_value() = Random.GLOBAL_RNG
6255
end
6356

57+
"""
58+
default_rng_value()
59+
60+
Create an instance of the default RNG depending on Julia's version.
61+
- Julia version is < 1.7: `Random.GLOBAL_RNG`
62+
- Julia version is >= 1.7: `Random.default_rng()`
63+
"""
64+
default_rng_value
65+
6466
"""
6567
glorot_uniform([rng = default_rng_value()], size...; gain = 1) -> Array
6668
glorot_uniform([rng]; kw...) -> Function

0 commit comments

Comments
 (0)