-
-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
MWE:
cpx(l,x)=real(l)+x;
f(x)=sum(@. real(cpx(im+x,x)))
x=ones(10);
Zygote.gradient(f,x);output:
ERROR: DimensionMismatch: a has size (4,), b has size (2,), mismatch at dim 1
Stacktrace:
[1] throw_promote_shape_mismatch(a::Tuple{Base.OneTo{Int64}}, b::Tuple{Base.OneTo{Int64}}, i::Int64)
@ Base .\indices.jl:135
[2] promote_shape(a::Tuple{Base.OneTo{Int64}}, b::Tuple{Base.OneTo{Int64}})
@ Base .\indices.jl:196
[3] promote_shape(a::ForwardDiff.Partials{4, Float64}, b::ForwardDiff.Partials{2, Float64})
@ Base .\indices.jl:188
[4] +(A::ForwardDiff.Partials{4, Float64}, B::ForwardDiff.Partials{2, Float64})
@ Base .\arraymath.jl:7
[5] +
@ C:\Users\Nicola\.julia\packages\ForwardDiff\egQMG\src\dual.jl:502 [inlined]
[6] cpx(l::Complex{ForwardDiff.Dual{Nothing, Float64, 4}}, x::ForwardDiff.Dual{Nothing, Float64, 2})
@ Main .\REPL[11]:1
[7] (::Zygote.var"#dual_function##0#dual_function##1"{typeof(cpx)})(::ComplexF64, ::Float64)
@ Zygote C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\lib\broadcast.jl:277
[8] _broadcast_getindex_evalf
@ .\broadcast.jl:699 [inlined]
[9] _broadcast_getindex
@ .\broadcast.jl:672 [inlined]
[10] _getindex
@ .\broadcast.jl:620 [inlined]
[11] getindex
@ .\broadcast.jl:616 [inlined]
[12] copy
@ .\broadcast.jl:933 [inlined]
[13] materialize
@ .\broadcast.jl:894 [inlined]
[14] broadcast_forward
@ C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\lib\broadcast.jl:283 [inlined]
[15] _broadcast_generic
@ C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\lib\broadcast.jl:213 [inlined]
[16] adjoint
@ C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\lib\broadcast.jl:206 [inlined]
[17] _pullback(::Zygote.Context{…}, ::typeof(Base.Broadcast.broadcasted), ::Base.Broadcast.DefaultArrayStyle{…}, ::typeof(cpx), ::Vector{…}, ::Vector{…})
@ Zygote C:\Users\Nicola\.julia\packages\ZygoteRules\CkVIK\src\adjoint.jl:67
[18] _apply(::Function, ::Vararg{Any})
@ Core .\boot.jl:1019
[19] adjoint
@ C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\lib\lib.jl:211 [inlined]
[20] _pullback
@ C:\Users\Nicola\.julia\packages\ZygoteRules\CkVIK\src\adjoint.jl:67 [inlined]
[21] broadcasted
@ .\broadcast.jl:1352 [inlined]
[22] f
@ .\REPL[12]:1 [inlined]
[23] _pullback(ctx::Zygote.Context{false}, f::typeof(f), args::Vector{Float64})
@ Zygote C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\compiler\interface2.jl:0
[24] pullback(f::Function, cx::Zygote.Context{false}, args::Vector{Float64})
@ Zygote C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\compiler\interface.jl:96
[25] pullback
@ C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\compiler\interface.jl:94 [inlined]
[26] gradient(f::Function, args::Vector{Float64})
@ Zygote C:\Users\Nicola\.julia\packages\Zygote\55SqB\src\compiler\interface.jl:153
[27] top-level scope
@ REPL[13]:1
Some type information was truncated. Use `show(err)` to see complete types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels