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

Limitations of FiniteDifferences.to_vec for Tangent() #271

Open
theogf opened this issue Feb 21, 2023 · 1 comment
Open

Limitations of FiniteDifferences.to_vec for Tangent() #271

theogf opened this issue Feb 21, 2023 · 1 comment

Comments

@theogf
Copy link
Contributor

theogf commented Feb 21, 2023

to_vec is great for working on complex structures but it has the limit of only reconstructing the primal representation.

For example, related to #270 , if I had a to_vec(x::AbstractVector{T,Missing}) where {T} definition such as:

function to_vec(x::AbstractVector{T,Missing}) where {T}
   is = findall(ismissing, x)
   not_is = findall(!ismissing, x)
   xval, from_xval = to_vec(x[is])
   function from_vec(x)
      y = similar(x)
      y[is] = from_xval(x)
      y[not_is] .= missing
      y
   end
   xval, from_vec
end

The primal reconstruction would work fine, but instead of returning some NoTangent for the missing values, it would just return missing and mess up the rest.

One solution would be to specify a dual version which would put the right Tangent types where needed.

@oxinabox
Copy link
Member

oxinabox commented Feb 22, 2023

In the long term we want to move away from to_vec entirely and just have FiniteDifferences work on Tangent objects etc directly.

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

2 participants