Skip to content

TrackedComplex types #54

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

TrackedComplex types #54

wants to merge 6 commits into from

Conversation

gszep
Copy link

@gszep gszep commented Nov 4, 2019

want a TrackedComplex type so that I can efficiently differentiate through FFTW.fft and also opens up the possibility of teaching Tracker complex analysis, contour integrals etc.

@gszep
Copy link
Author

gszep commented Nov 4, 2019

the following works as expected

using Flux
z = param([1-im,1+im])
typeof(z) # TrackedArray{…,Array{Complex{Float64},1}}
eltype(z) # TrackedComplex{Complex{Float64}}

but tracking is lost on element-wise vector operations

julia> exp(z[1])
1.4686939399158851 - 2.2873552871788423im (tracked)

julia> exp.(real(z))
Tracked 2-element Array{Float64,1}:
 2.718281828459045
 2.718281828459045

julia> exp.(z) # tracking lost
2-element Array{Complex{Float64},1}:
 1.4686939399158851 - 2.2873552871788423im
 1.4686939399158851 + 2.2873552871788423im

might have something to do with the fact that we can't subtype concrete type
TrackedComplex{T<:Complex} <: Complex

@gszep gszep mentioned this pull request Nov 4, 2019
@gszep
Copy link
Author

gszep commented Nov 5, 2019

exp.(z) # tracking works!

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

Successfully merging this pull request may close these issues.

1 participant