Feature request: Support python control flow in `custom_transforms` functions
See original GitHub issueFor fitting parameter values for ODEs a la the adjoint sensitivity method, we might want to override the gradient computation for the forward ODE solve. More concretely, we might have an integrator function odeint
that takes in a gradient field f
, initial state y0
, and a sequence of times ts
to be evaluated at.
One specific use case where supporting control-flow in custom_transforms
will be useful is for the backward integration (which might involve adaptive solvers, hence non-trivial control-flow). Ideally, we would like to write code as follows
@custom_transforms
def odeint(y0, ts):
pass # Some procedure integrating the vector field `f`.
def vjp_y0(g, ans, y0, ts):
pass # A while loop and some if statements used to determine integration step size.
defvjp(odeint, vjp_y0, None)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
PEP 42 – Feature Requests - Python Enhancement Proposals
Introduction. This PEP contains a list of feature requests that may be considered for future versions of Python. Large feature requests should ...
Read more >Python's Requests Library (Guide)
In this tutorial on Python's "requests" library, you'll see some of the most useful features that requests has to offer as well as...
Read more >Advanced Usage — Requests 2.28.1 documentation
This document covers some of Requests more advanced features. Session Objects¶. The Session object allows you to persist certain parameters across requests. It ......
Read more >Custom Transforms in Lab Automation
Custom Transforms are a way to inject arbitrary logic into Lab Automation's processing pipeline. The user will upload a file to a Run's...
Read more >Creating a Custom Data Transformer using Scikit-Learn
In this article, we will learn how to build the custom data transformers using Scikit-Learn and look at an example to implement the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We’re working on this. The reason it isn’t as simple as it was for Autograd is that JAX uses a new autodiff design in which we only have forward mode and derive reverse mode automatically (composing forward mode with other transformations). That confers several advantages, but a disadvantage is that since the system itself doesn’t work in terms of VJPs, supporting custom VJPs is tricky. (You can write custom JVPs, ie forward-mode rules, with arbitrary Python control flow now.)
#2026 finally landed and added support for Python control flow in custom derivative rules! (The API also changed, so take a look at the tutorial notebook.)