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

Broadcast max is not supported #512

Closed
weymouth opened this issue Mar 23, 2021 · 0 comments
Closed

Broadcast max is not supported #512

weymouth opened this issue Mar 23, 2021 · 0 comments

Comments

@weymouth
Copy link

weymouth commented Mar 23, 2021

This was a bad MWE! Nevermind.

Perhaps I'm doing something silly, but it looks like broadcasted max is not supported as a differentiable function?

> using ForwardDiff
> f(x::Vector) = max.(x,0.);
> g = x-> ForwardDiff.gradient(f,x);
> x = rand(3)
0.326712
0.362656
0.832167
> f(x)
0.326712
0.362656
0.832167
> g(x)
MethodError: no method matching extract_gradient!(::Type{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64}}, ::Array{Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3},1},1}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3},1})

Closest candidates are:

extract_gradient!(::Type{T}, ::AbstractArray, !Matched::ForwardDiff.Dual) where T at /Users/weymouth/.julia/packages/ForwardDiff/qTmqf/src/gradient.jl:79

extract_gradient!(::Type{T}, ::AbstractArray, !Matched::Real) where T at /Users/weymouth/.julia/packages/ForwardDiff/qTmqf/src/gradient.jl:78

extract_gradient!(::Type{T}, !Matched::DiffResults.DiffResult, !Matched::ForwardDiff.Dual) where T at /Users/weymouth/.julia/packages/ForwardDiff/qTmqf/src/gradient.jl:72

...

vector_mode_gradient(::typeof(Main.workspace397.f), ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3},1}})@gradient.jl:101
gradient(::Function, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3},1}}, ::Val{true})@gradient.jl:19
gradient(::Function, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(Main.workspace397.f),Float64},Float64,3},1}})@gradient.jl:17
(::Main.workspace397.var"#1#2")(::Array{Float64,1})@Other: 1
top-level scope@Local: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant