Replies: 6 comments 1 reply
-
|
Hi Ben, thanks for reaching out---I agree that some utilities for coupling Jaxley with other libraries that are based on vectors would be useful. I am not yet sure what the best place for such utilities would be though. A few options:
To get started, I tend towards the first option, at least as long as it is rather little code. As the code base grows bigger, we might want to migrate to option 2. Regarding point 2: You might aware of this anyways, but I think import jax
import jax.numpy as jnp
# Example pytree: dict of arrays
pytree = {
"a": jnp.array([1., 2.]),
"b": jnp.array([3., 4., 5.])
}
# Flatten into 1D array
flat, unravel = jax.flatten_util.ravel_pytree(pytree)
print(flat) # 1D array: [1. 2. 3. 4. 5.]
print(flat.shape) # (5,)
# Recover original pytree structure
restored = unravel(flat)
print(restored)Anyways...if you would be up for getting started with this, that would be awesome. If you need input, let us know (but I will be on vacation next week :) ). All the best |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the quick reply @michaeldeistler ! I agree that putting it inside of the utils would make sense. Let me clean up my example code and send it over in this thread, then we can decide what to do with it. I do have one question for you though. I've struggled to settle on the best design for handling the conversion between trainable_parameters and all parameters. If possible, I'd like to avoid calling module.get_all_parameters inside of the |
Beta Was this translation helpful? Give feedback.
-
|
Thanks Michael! I have a working version that includes the channel currents as part of the state vector, but I'm struggling to figure out how to accomplish this when I need my state vector to exclude the channel currents. I'll paste what I have so far below. The issue I'm having is how to write the |
Beta Was this translation helpful? Give feedback.
-
|
Hi @bantin! I agree that this would be a super useful thing to have in Jaxley! Both for filtering algorithms and e.g., computing Jacobians (see also discussion 699), among others! Coincidentally, I also just started working on this, here is what I got so far - it seems to be Here is an example run using these functions:
I haven't had time to compare our implementations in detail, but will have a look again later in the coming week! In any case posting this already in case it helps you in some way. |
Beta Was this translation helpful? Give feedback.
-
|
Awesome, thanks @Matthijspals ! I was able to plug your code into our filtering setup quite easily. Would be awesome to have this as part of jaxley. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I opened an Issue for this Issue #717, and will start working on a pull-request. Please let me know if you run into anything! |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hi jaxley folks!
I frequently find myself needing to work directly with the jaxley ODE dynamics function. In order to do various mathematical operations (e.g kalman smoothing) I need a dynamics function that looks something like this:
next_state_vector = dynamics_fn(state_vector, trainable_params, input_current)Since the channel currents can be computed deterministically from the voltage + channel states, I need the state vector to exclude the currents. While I can create this function using Jaxley, it is currently very cumbersome to do so. I think there are a few things that are making it difficult:
module.get_all_parameters()every time I need to evolve the state, which seems suboptimal and potentially slow (though I haven't timed it carefully)I'm wondering if the jaxley team would be interested in adding functionality to jaxley that makes it easier to get a
dynamics_fnthat works directly with vectors? I suspect that I'm not the only one interested in this, and I'd be happy to work on implementing it.Beta Was this translation helpful? Give feedback.
All reactions