Skip to content

Commit 73351c7

Browse files
authored
Update src/functor.jl
1 parent e21b094 commit 73351c7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/functor.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,23 @@ The behaviour of `params` on custom types can be customized using [`Functor.@fun
6060
6161
# Examples
6262
```jldoctest
63-
julia> params(Chain(Dense(ones(2,3))), softmax)
63+
julia> params(Chain(Dense(ones(2,3)), softmax)) # unpacks Flux models
6464
Params([[1.0 1.0 1.0; 1.0 1.0 1.0], [0.0, 0.0]])
6565
66-
julia> params(BatchNorm(2, relu))
66+
julia> bn = BatchNorm(2, relu)
67+
BatchNorm(2, relu) # 4 parameters, plus 4 non-trainable
68+
69+
julia> params(bn) # only the trainable parameters
6770
Params([Float32[0.0, 0.0], Float32[1.0, 1.0]])
71+
72+
julia> params([1, 2, 3], [4.0]) # one or more arrays of numbers
73+
Params([[1, 2, 3], [4.0]])
74+
75+
julia> params([[1, 2, 3], [4.0]]) # unpacks array of arrays
76+
Params([[1, 2, 3], [4.0]])
77+
78+
julia> params(1, [2 2], (alpha=[3,3,3], beta=Ref(4), gamma=sin)) # ignores scalars, unpacks NamedTuples
79+
Params([[2 2], [3, 3, 3]])
6880
```
6981
"""
7082
function params(m...)

0 commit comments

Comments
 (0)