Skip to content

Commit

Permalink
add noisy warnings to train! and update! too.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Nov 25, 2024
1 parent 043fd57 commit 130e04c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/optimise/train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ function update!(opt::AbstractOptimiser, x::AbstractArray, x̄)
end

function update!(opt::AbstractOptimiser, xs::Params, gs)
@warn """The method `Flux.update!(optimiser, ps::Params, grads)` is deprecated,

Check warning on line 8 in src/optimise/train.jl

View check run for this annotation

Codecov / codecov/patch

src/optimise/train.jl#L8

Added line #L8 was not covered by tests
as part of Flux's move away from Zyote's implicit mode.
Please use explicit-style `update!(opt_state, model, grad)` instead,
where `grad = Flux.gradient(m -> loss(m,x,y), model)` and `opt_state = Flux.setup(rule, model)`.""" maxlog=1
for x in xs
isnothing(gs[x]) && continue
update!(opt, x, gs[x])
Expand All @@ -21,6 +25,10 @@ batchmemaybe(x) = tuple(x)
batchmemaybe(x::Tuple) = x

function train!(loss, ps::Params, data, opt::AbstractOptimiser; cb = () -> ())
@warn """The method `Flux.train!(loss2, ps::Params, data, optimiser)` is deprecated,

Check warning on line 28 in src/optimise/train.jl

View check run for this annotation

Codecov / codecov/patch

src/optimise/train.jl#L28

Added line #L28 was not covered by tests
as part of Flux's move away from Zyote's implicit parameters.
Please use explicit-style `train!(loss, model, data, opt_state)` instead,
where `loss(m, xy...)` accepts the model, and `opt_state = Flux.setup(rule, model)`.""" maxlog=1
cb = runall(cb)
itrsz = Base.IteratorSize(typeof(data))
n = (itrsz == Base.HasLength()) || (itrsz == Base.HasShape{1}()) ? length(data) : 0
Expand Down

0 comments on commit 130e04c

Please sign in to comment.