Saving metrics during solve
See original GitHub issueHi, thanks again for the library.
we have a numerical integration we perform using lax.scan
. We’d like to port it over to diffrax
. I wanted to get your thoughts on the shortest path to this implementation.
From https://jax.readthedocs.io/en/latest/_autosummary/jax.lax.scan.html
def scan(f, init, xs, length=None):
if xs is None:
xs = [None] * length
carry = init
ys = []
for x in xs:
carry, y = f(carry, x)
ys.append(y)
return carry, np.stack(ys)
we rely quite a bit on the implicit append
and stack
calls that happen inside lax.scan
. I think the core of my question is, is there a way to avoid the pre-allocation as you suggest in https://github.com/patrick-kidger/diffrax/issues/60#issuecomment-1034768386 . My guess is the answer is no but figured I’d see if you had any ideas.
TY in advance!
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
The Importance of Implementing Effective Metrics - iSixSigma
Metrics indicate the priorities of the company and provide a window on performance, ethos and ambition. Ultimately, metrics will help tell the organization: ......
Read more >Understanding The Problem You're Trying to Solve With Metrics
Metrics aren't going to help if you don't understand the problem you're trying to solve by implementing them. Learn more in this episode...
Read more >Don't Let Metrics Undermine Your Business
Let's try to solve this problem—and by the way, here's some data we can look at to see how we're doing.'” Loosen the...
Read more >6 Key Metrics to Track When Automating Your Business - Make
6 key metrics to track when automating your business. 1. Time saved. In the business world, people like to say that there aren't...
Read more >9 Tips for Using HR Metrics Strategically - SHRM
Though metrics can be used to monitor performance, most data scientists emphasize their use in gathering the intelligence needed to resolve ...
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 FreeTop 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
Top GitHub Comments
Sounds good! I’ve adjusted the title of this issue to make this a feature request. (Which if you ever feel like digging into the guts of Diffrax I’d be happy to shepard a PR on.)
Yep! It’s this big block of code. The idea will be to change from
state.ys
– which is where we save our output – tostate.out
.Now the bad news is that this part of the code is pretty complicated to read, as it needs to carefully make sure it gets good performance. Fortunately the good news is that you shouldn’t need to change any of that – just carefully figure out what’s what, and replace saving
ys
with savingsave_fn(ys)
.I’d suggest that the saving-function should be specified as part of the
diffeqsolve(..., saveat=...)
argument, and that when called it should takestate
as an argument.As a nice bonus, I’ve realised that this makes the
solver_state
,controller_state
,made_jump
arguments toSaveAt
superfluous: these can be obtained simply by using the appropriate metric-saving function.