jax-ml / jax

Composable transformations of Python+NumPy programs: differentiate, vectorize, JIT to GPU/TPU, and more
http://jax.readthedocs.io/
Apache License 2.0
30.52k stars 2.8k forks source link

cannot `import optimizers' from 'jax.experimental' even though `import stax` works #372

Closed murphyk closed 5 years ago

murphyk commented 5 years ago

I typed

pip install --upgrade jax jaxlib  # CPU-only version

and the tests pass. Now I am trying to run the first order opt demo from here.. I get this error

from jax.experimental import optimizers
ImportError: cannot import name 'optimizers' from 'jax.experimental' (/home/kpmurphy/anaconda3/lib/python3.7/site-packages/jax/experimental/__init__.py)

even though from jax.experimental import stax works fine.

I am using jax==0.1.18, jaxlib==0.1.7 on a pixelbook.

hawkinsp commented 5 years ago

I think this is a version difference — until we release a new jax wheel, the module is still called minmax. (This was apparently an unwise choice of name because of potential confusion with minimax.)

Try jax.experimental.minmax.

murphyk commented 5 years ago

that works, thx

aamirf316 commented 9 months ago

I am using google colab and "!pip install optax ! pip install --upgrade jax jaxlib import numpy as onp from scipy.integrate import solve_ivp import jax.numpy as np from jax import random, grad, vmap, jit from jax.experimental import optimizers from jax.experimental.ode import odeint from jax.nn import relu, sigmoid from jax.config import config from jax.lax import scan, fori_loop

from jax.flatten_util import ravel_pytree import itertools from functools import partial from torch.utils import data from tqdm import trange

import matplotlib.pyplot as plt

%matplotlib inline and I got the same error and I used all the formats but not working "ImportError: cannot import name 'optimizers' from 'jax.experimental' (/usr/local/lib/python3.10/dist-packages/jax/experimental/init.py)" and I am doinf stiff folder "https://github.com/PredictiveIntelligenceLab/Long-time-Integration-PI-DeepONets"

rookiiiie commented 8 months ago

from jax.experimental import optimizers

hello!Rencently i met the same problem,have u solved?

rookiiiie commented 8 months ago

I download the latest jaxlib folder and search "optimizers",i find the package path has changed!from "from jax.experimental import optimizers" to "from jax.example_libraries import optimizers" ,u can have a try😁

jakevdp commented 8 months ago

Please note that jax.experimental.optimizers was moved to jax.example_libraries in JAX v0.2.25, and the old path was removed in JAX v0.3.16.