Skip to content

Commit 3d7e644

Browse files
authored
Fix some typos, spelling etc. in FAQ.md (#432)
1 parent 1014715 commit 3d7e644

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

docs/src/FAQ.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
### `Δx`, `∂x`, `dx`
66
ChainRules uses these perhaps atypically.
7-
As a notation that is the same across propagators, regardless of direction (incontrast see `` and `` below).
7+
As a notation that is the same across propagators, regardless of direction (in contrast see `` and `` below).
88

9-
- `Δx` is the input to a propagator, (i.e a _seed_ for a _pullback_; or a _perturbation_ for a _pushforward_)
10-
- `∂x` is the output of a propagator
11-
- `dx` could be either `input` or `output`
9+
- `Δx` is the input to a propagator, (i.e a _seed_ for a _pullback_; or a _perturbation_ for a _pushforward_).
10+
- `∂x` is the output of a propagator.
11+
- `dx` could be either `input` or `output`.
1212

1313

1414
### dots and bars: ``\dot{y} = \dfrac{∂y}{∂x} = \overline{x}``
@@ -28,16 +28,19 @@ Why not just return the pushforward/pullback, and let the user call `f(x)` to ge
2828
There are three reasons the rules also calculate the `f(x)`.
2929
1. For some rules an alternative way of calculating `f(x)` can give the same answer while also generating intermediate values that can be used in the calculations required to propagate the derivative.
3030
2. For many `rrule`s the output value is used in the definition of the pullback. For example `tan`, `sigmoid` etc.
31-
3. For some `frule`s there exists a single, non-separable operation that will compute both derivative and primal result. For example many of the methods for [differential equation sensitivity analysis](https://docs.juliadiffeq.org/stable/analysis/sensitivity/#sensitivity-1).
31+
3. For some `frule`s there exists a single, non-separable operation that will compute both derivative and primal result. For example, this is the case for many of the methods for [differential equation sensitivity analysis](https://docs.juliadiffeq.org/stable/analysis/sensitivity/#sensitivity-1).
3232

3333
For more information and examples see the [design notes on changing the primal](@ref change_primal).
3434

3535
## Where are the derivatives for keyword arguments?
36-
_pullbacks_ do not return a sensitivity for keyword arguments;
37-
similarly _pushfowards_ do not accept a perturbation for keyword arguments.
36+
37+
_Pullbacks_ do not return a sensitivity for keyword arguments;
38+
similarly, _pushforwards_ do not accept a perturbation for keyword arguments.
3839
This is because in practice functions are very rarely differentiable with respect to keyword arguments.
39-
As a rule keyword arguments tend to control side-effects, like logging verbosity,
40-
or to be functionality changing to perform a different operation, e.g. `dims=3`, and thus not differentiable.
40+
41+
As a rule, keyword arguments tend to control side-effects, like logging verbosity,
42+
or to be functionality-changing to perform a different operation, e.g. `dims=3`, and thus not differentiable.
43+
4144
To the best of our knowledge no Julia AD system, with support for the definition of custom primitives, supports differentiating with respect to keyword arguments.
4245
At some point in the future ChainRules may support these. Maybe.
4346

@@ -47,13 +50,13 @@ At some point in the future ChainRules may support these. Maybe.
4750
Odds are if you write a rule that returns the wrong one everything will just work fine.
4851
We provide both to allow for clearer writing of rules, and easier debugging.
4952

50-
`ZeroTangent()` represents the fact that if one perturbs (adds a small change to) the matching primal there will be no change in the behaviour of the primal function.
51-
For example in `fst(x,y) = x`, then the derivative of `fst` with respect to `y` is `ZeroTangent()`.
52-
`fst(10, 5) == 10` and if we add `0.1` to `5` we still get `fst(10, 5.1)=10`.
53+
`ZeroTangent()` represents the fact that if one perturbs (adds a small change to) the matching primal, there will be no change in the behaviour of the primal function.
54+
For example, in `fst(x, y) = x`, the derivative of `fst` with respect to `y` is `ZeroTangent()`.
55+
`fst(10, 5) == 10` and if we add `0.1` to `5` we still get `fst(10, 5.1) == 10`.
5356

5457
`NoTangent()` represents the fact that if one perturbs the matching primal, the primal function will now error.
55-
For example in `access(xs, n) = xs[n]` then the derivative of `access` with respect to `n` is `NoTangent()`.
56-
`access([10, 20, 30], 2) = 20`, but if we add `0.1` to `2` we get `access([10, 20, 30], 2.1)` which errors as indexing can't be applied at fractional indexes.
58+
For example, in `access(xs, n) = xs[n]`, the derivative of `access` with respect to `n` is `NoTangent()`.
59+
`access([10, 20, 30], 2) == 20`, but if we add `0.1` to `2` we get `access([10, 20, 30], 2.1)` which errors as indexing can't be applied at fractional indexes.
5760

5861

5962
## When to use ChainRules vs ChainRulesCore?
@@ -62,24 +65,24 @@ For example in `access(xs, n) = xs[n]` then the derivative of `access` with resp
6265
It has almost no dependencies of its own.
6366
If you only want to define rules, not use them, then you probably only want to load ChainRulesCore.jl.
6467

65-
[ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl) provides the full functionality for AD systems, in particular it has all the rules for Base Julia and the standard libraries.
68+
[ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl) provides the full functionality for AD systems. In particular, it has all the rules for Base Julia and the standard libraries.
6669
It is thus a much heavier package to load.
6770
AD systems making use of `frule`s and `rrule`s should load ChainRules.jl.
6871

6972
## Where should I put my rules?
7073

7174
We recommend adding custom rules to your own packages with [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl).
72-
It is good to have them in the same pacakge that defines the original function.
75+
It is good to have them in the same package that defines the original function.
7376
This avoids type-piracy, and makes it easy to keep in-sync.
74-
ChainRulesCore is a very light weight dependency.
77+
ChainRulesCore is a very light-weight dependency.
7578

7679
## How do I test my rules?
7780

7881
You can use [ChainRulesTestUtils.jl](https://github.com/JuliaDiff/ChainRulesTestUtils.jl) to test your custom rules.
7982
ChainRulesTestUtils.jl has some dependencies, so it is a separate package from ChainRulesCore.jl.
8083
This means your package can depend on the light-weight ChainRulesCore.jl, and make ChainRulesTestUtils.jl a test-only dependency.
8184

82-
Remember to read the section on [On writing good `rrule` / `frule` methods](@ref).
85+
Remember to read the section [On writing good `rrule` / `frule` methods](@ref).
8386

8487
## Where can I learn more about AD ?
8588
There are not so many truly excellent learning resources for autodiff out there in the world, which is a bit sad.
@@ -103,9 +106,9 @@ It also covers forward-mode though (by its own admission) not as well, it never
103106
## Is removing a thunk a breaking change?
104107
Removing thunks is not considered a breaking change.
105108
This is because (in principle) removing them changes the implementation of the values
106-
returned by an rrule, not the value that they represent.
109+
returned by an `rrule`, not the value that they represent.
107110
This is morally the same as similar issues [discussed in ColPrac](https://github.com/SciML/ColPrac#changes-that-are-not-considered-breaking), such as details of floating point arithmetic changing.
108111

109-
On a practical level, it's important that this is the case because thunks a bit of a hack,
112+
On a practical level, it's important that this is the case because thunks are a bit of a hack,
110113
and over time it is hoped that the need for them will reduce, as they increase
111114
code-complexity and place additional stress on the compiler.

0 commit comments

Comments
 (0)