55"""
66 Optimisers.freeze!(tree)
77
8- Temporarily alters the state `tree = setup(rule, model)` so that parameters will not be updated.
9- Can be applied to the state corresponding to only part of a model, for instance `model.layers[1]`.
10- Un-done by [`thaw!`](@ref Optimisers.thaw).
8+ Temporarily alters the state `tree = setup(rule, model)` so that parameters
9+ will not be updated. Un-done by [`thaw!`](@ref Optimisers.thaw!).
10+
11+ Can be applied to the state corresponding to only part of a model,
12+ for instance with `model::Chain`, to freeze `model.layers[1]` you
13+ should call `freeze!(tree.layers[1])`.
1114
1215# Example
1316```jldoctest
@@ -31,16 +34,16 @@ julia> s.x
3134(Leaf(Momentum{Float32}(0.01, 0.9), [0.0]), ())
3235```
3336"""
34- freeze! (tree) = ( fmapstructure ( freeze!, tree; exclude = x -> x isa Leaf); nothing )
37+ freeze! (tree) = foreach ( freeze!, tree)
3538freeze! (ℓ:: Leaf ) = (ℓ. frozen = true ; nothing )
3639
3740"""
3841 Optimisers.thaw!(tree)
3942
40- Un-does [`freeze!`](@ref Optimisers.freeze!) for all parameters,
41- mutating every `Leaf(rule, state, true)` to `Leaf(rule, state, false)`.
43+ The reverse of [`freeze!`](@ref Optimisers.freeze!). Applies to all parameters,
44+ mutating every `Leaf(rule, state, frozen = true)` to `Leaf(rule, state, frozen = false)`.
4245"""
43- thaw! (tree) = ( fmapstructure ( thaw!, tree; exclude = x -> x isa Leaf); nothing )
46+ thaw! (tree) = foreach ( thaw!, tree)
4447thaw! (ℓ:: Leaf ) = (ℓ. frozen = false ; nothing )
4548
4649freeze! (:: Union{Number, AbstractArray{<:Number}} ) = throw (ArgumentError (
0 commit comments