5
5
"""
6
6
Optimisers.freeze!(tree)
7
7
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])`.
11
14
12
15
# Example
13
16
```jldoctest
@@ -31,16 +34,16 @@ julia> s.x
31
34
(Leaf(Momentum{Float32}(0.01, 0.9), [0.0]), ())
32
35
```
33
36
"""
34
- freeze! (tree) = ( fmapstructure ( freeze!, tree; exclude = x -> x isa Leaf); nothing )
37
+ freeze! (tree) = foreach ( freeze!, tree)
35
38
freeze! (ℓ:: Leaf ) = (ℓ. frozen = true ; nothing )
36
39
37
40
"""
38
41
Optimisers.thaw!(tree)
39
42
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)`.
42
45
"""
43
- thaw! (tree) = ( fmapstructure ( thaw!, tree; exclude = x -> x isa Leaf); nothing )
46
+ thaw! (tree) = foreach ( thaw!, tree)
44
47
thaw! (ℓ:: Leaf ) = (ℓ. frozen = false ; nothing )
45
48
46
49
freeze! (:: Union{Number, AbstractArray{<:Number}} ) = throw (ArgumentError (
0 commit comments