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

Differentiation in arrays where len(X.shape)>2? #40

Closed
yb6599 opened this issue Feb 21, 2024 · 1 comment · Fixed by #41
Closed

Differentiation in arrays where len(X.shape)>2? #40

yb6599 opened this issue Feb 21, 2024 · 1 comment · Fixed by #41
Labels
enhancement New feature or request

Comments

@yb6599
Copy link

yb6599 commented Feb 21, 2024

Pertaining to this issue,

While trying to differentiate an array with len(X.shape) = 3, for example X.shape = (10, 100, 2) and t = np.arange(0, 10, 0.1), since X is not 2-dimensional, I get the error "Invalid Shape of X".
Without having to manipulate the shape of X, is it possible to implement differentiation of multidimensional arrays?

@andgoldschmidt
Copy link
Owner

It should be possible. The _align_axes(X, t, axis) and _restore_axes(dX, axis, flat) routines in differentiation.py can likely be adapted in a way that would enable the derived dimension to be any axis.

In the current version, the indices are arranged into batch x time, and the default behavior of derivative is to loop over each batch dimension. This doesn't leverage vectorization or multithreading, so it's not really performant. But, a possible minimal change would be to reshape internally into batch x time and then back into the original shape after the computation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants