Skip to content

Commit 600a17c

Browse files
authored
Docstring for isnumeric (#104)
* docstring for isnumeric * add isnumeric to docs * change order of two docstrings
1 parent d5a374b commit 600a17c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/src/api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ Optimisers.update!
3737
Optimisers.adjust(::Any, ::Real)
3838
```
3939

40-
Calling `Functors.@functor` on your model's layer types by default causes the
41-
optimiser to act on all suitable fields. To restrict this, define `trainable`:
40+
Calling `Functors.@functor` on your model's layer types by default causes
41+
these functions to recurse into all children, and ultimately optimise
42+
all `isnumeric` leaf nodes.
43+
To further restrict this by ignoring some fields of a layer type, define `trainable`:
4244

4345
```@docs
46+
Optimisers.isnumeric
4447
Optimisers.trainable
4548
```
4649

src/interface.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ end
5252
# default all rules to first order calls
5353
apply!(o, state, x, dx, dxs...) = apply!(o, state, x, dx)
5454

55+
"""
56+
isnumeric(x) -> Bool
57+
58+
Returns `true` on any parameter to be adjusted by Optimisers.jl,
59+
namely arrays of non-integer numbers. Returns `false` on all other types.
60+
61+
Requires also that `Functors.isleaf(x) == true`, to focus on e.g. the
62+
parent of a transposed matrix, not the wrapper.
63+
"""
5564
isnumeric(x::AbstractArray{<:Number}) = isleaf(x) # isleaf to allow for e.g. transposed shared weights
5665
isnumeric(x::AbstractArray{<:Integer}) = false
5766
isnumeric(x) = false

0 commit comments

Comments
 (0)