Skip to content

Commit

Permalink
rm gradient definitions, now in Zygote 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Abbott committed Dec 21, 2020
1 parent b70ee4c commit c7b9cd3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 42 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ NNlib = "0.7"
Reexport = "0.2"
StatsBase = "0.33"
ZipFile = "0.9"
Zygote = "0.5"
Zygote = "0.6"
julia = "1.5"

[extras]
Expand Down
41 changes: 0 additions & 41 deletions src/deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,3 @@ function Broadcast.broadcasted(::typeof(logitbinarycrossentropy), ŷ, y)
@warn "logitbinarycrossentropy.(ŷ, y) is deprecated, use Losses.logitbinarycrossentropy(ŷ, y, agg=identity) instead"
Losses.logitbinarycrossentropy(ŷ, y, agg=identity)
end


# To move to Zygote

using Base.Broadcast: broadcasted


Zygote.@adjoint function broadcasted(::typeof(+), a::AbstractArray{<:Number}, b::Bool)
y = b === false ? a : a .+ b
y, Δ -> (nothing, Δ, nothing)
end
Zygote.@adjoint function broadcasted(::typeof(+), b::Bool, a::AbstractArray{<:Number})
y = b === false ? a : b .+ a
y, Δ -> (nothing, nothing, Δ)
end


Zygote.@adjoint function broadcasted(::typeof(-), a::AbstractArray{<:Number}, b::Bool)
y = b === false ? a : a .- b
y, Δ -> (nothing, Δ, nothing)
end
Zygote.@adjoint function broadcasted(::typeof(-), b::Bool, a::AbstractArray{<:Number})
b .- a, Δ -> (nothing, nothing, .-Δ)
end


Zygote.@adjoint function broadcasted(::typeof(*), a::AbstractArray{<:Number}, b::Bool)
if b === false
zero(a), Δ -> (nothing, zero(Δ), nothing)
else
a, Δ -> (nothing, Δ, nothing)
end
end
Zygote.@adjoint function broadcasted(::typeof(*), b::Bool, a::AbstractArray{<:Number})
if b === false
zero(a), Δ -> (nothing, nothing, zero(Δ))
else
a, Δ -> (nothing, nothing, Δ)
end
end

0 comments on commit c7b9cd3

Please sign in to comment.