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

Workaround for Mutating Arrays #137

Closed
bdas123 opened this issue Jun 14, 2022 · 4 comments
Closed

Workaround for Mutating Arrays #137

bdas123 opened this issue Jun 14, 2022 · 4 comments

Comments

@bdas123
Copy link

bdas123 commented Jun 14, 2022

Just out of curiosity, are there any workarounds for the "cannot handle mutating arrays" issue?

I'd like to know what has already worked in the past.

@mohamed82008
Copy link
Member

  1. Use AD packages other than Zygote, e.g. ForwardDiff and ReverseDiff
  2. Define an rrule using ChainRulesCore for your mutating function if it's simple enough to derive
  3. Avoid pre-allocation and use a non-mutating version of functions, e.g. use:
y = map(1:3) do i
  x[i]^2
end

instead of:

y = similar(x)
for i in 1:3
  y[i] = x[i]^2
end

@bdas123
Copy link
Author

bdas123 commented Jun 17, 2022

Is there documentation for going about the first option?

Since Nonconvex.jl is built on Zygote.jl, how do I specify to use ForwardDiff instead?

@mohamed82008
Copy link
Member

Check the docs of the latest release https://julianonconvex.github.io/Nonconvex.jl/stable/gradients/other_ad/.

@mohamed82008
Copy link
Member

I will consider this issue solved.

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