Skip to content

Commit a12569a

Browse files
Update src/functor.jl
Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
1 parent 2540027 commit a12569a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/functor.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ end
5151
"""
5252
params(model)
5353
54-
Given a model or specific layers from a model, return the trainable parameters
55-
such that they can be used as input to the `train!` function.
54+
Given a model or specific layers from a model, create a `Params` object pointing to its trainable parameters.
55+
56+
This can be used with [`gradient`](@ref), or as input to the [`Flux.train!`](@ref Flux.train!) function.
57+
58+
# Examples
59+
```jldoctest
60+
julia> params(Chain(Dense(ones(2,3))), softmax)
61+
Params([[1.0 1.0 1.0; 1.0 1.0 1.0], [0.0, 0.0]])
62+
63+
julia> params(BatchNorm(2, relu))
64+
Params([Float32[0.0, 0.0], Float32[1.0, 1.0]])
65+
```
5666
"""
5767
function params(m...)
5868
ps = Params()

0 commit comments

Comments
 (0)