Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update use of Flux._isactive in DropBlock to prevent deprecation warning #254

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Metalhead"
uuid = "dbeba491-748d-5e0e-a39e-b530a07fa0cc"
version = "0.8.4"
version = "0.9.0"

[deps]
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Expand Down
5 changes: 2 additions & 3 deletions src/layers/drop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ ChainRulesCore.@non_differentiable _dropblock_checks(x, drop_block_prob, gamma_s

function (m::DropBlock)(x)
_dropblock_checks(x, m.drop_block_prob, m.gamma_scale)
return Flux._isactive(m) ?
dropblock(m.rng, x, m.drop_block_prob, m.block_size, m.gamma_scale) : x
return dropblock(m.rng, x, m.drop_block_prob * Flux._isactive(m, x), m.block_size, m.gamma_scale)
end

function Flux.testmode!(m::DropBlock, mode = true)
return (m.active = (isnothing(mode) || mode === :auto) ? nothing : !mode; m)
return (m.active = isnothing(Flux._tidy_active(mode)) ? nothing : !mode; m)
end

function DropBlock(drop_block_prob = 0.1, block_size::Integer = 7, gamma_scale = 1.0,
Expand Down
Loading