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

Add the JAX backend #504

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

YannCabanes
Copy link
Contributor

Add the JAX backend: https://jax.readthedocs.io/en/latest/
The JAX backend can be used for automatic differentiation: https://jax.readthedocs.io/en/latest/notebooks/autodiff_cookbook.html

@YannCabanes
Copy link
Contributor Author

The following error is obtained:

tslearn/tests/test_metrics.py:15: in <module>
    backends = [Backend("numpy"), None]
tslearn/backend/backend.py:99: in __init__
    self.backend = select_backend(data)
tslearn/backend/backend.py:75: in select_backend
    backends_instances = [NumPyBackend(), JAXBackend(), PyTorchBackend()]
tslearn/backend/backend.py:13: in __init__
    raise ValueError("Could not use JAX backend since JAX is not installed.")
E   ValueError: Could not use JAX backend since JAX is not installed.

@YannCabanes
Copy link
Contributor Author

It seems from the previous error message that JAX is not installed during the continuous integration tests, therefore the tests in test_metrics.py are not running with the JAX backend.

On my local computer, these tests are failing with the following error message:

TypeError: '<class 'jaxlib.xla_extension.ArrayImpl'>' object does not support item assignment. JAX arrays are immutable. Instead of ``x[idx] = y``, use ``x = x.at[idx].set(y)`` or another .at[] method: https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.ndarray.at.html

@YannCabanes
Copy link
Contributor Author

@YannCabanes
Copy link
Contributor Author

A solution would be to create a class named JAXNumPyInterface which would define the operators of mutable objects.
The Python operators are listed here: https://docs.python.org/3/library/operator.html

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

Successfully merging this pull request may close these issues.

1 participant