Skip to content

Commit 9015713

Browse files
vrouletOptaxDev
authored andcommitted
Clean dependencies
PiperOrigin-RevId: 748836033
1 parent d2f19fd commit 9015713

9 files changed

Lines changed: 29 additions & 45 deletions

docs/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ def _recursive_add_annotations_import():
199199
'cifar10_resnet.ipynb',
200200
'adversarial_training.ipynb',
201201
'reduce_on_plateau.ipynb',
202-
'differentially_private_sgd.ipynb'
202+
'differentially_private_sgd.ipynb',
203+
'lookahead_mnist.ipynb',
204+
'mlp_mnist.ipynb',
203205
]
204206

205207
# -- Options for katex ------------------------------------------------------

examples/adversarial_training.ipynb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"\n",
1212
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/optax/blob/main/examples/adversarial_training.ipynb)\n",
1313
"\n",
14-
"\n",
1514
"The following code trains a convolutional neural network (CNN) to be robust\n",
1615
"with respect to the projected gradient descent (PGD) method.\n",
1716
"\n",
@@ -28,7 +27,11 @@
2827
" and harnessing adversarial examples.\", https://arxiv.org/abs/1412.6572\n",
2928
"\n",
3029
" Madry, Aleksander, et al. \"Towards deep learning models resistant to\n",
31-
" adversarial attacks.\", https://arxiv.org/abs/1706.06083"
30+
" adversarial attacks.\", https://arxiv.org/abs/1706.06083\n",
31+
"\n",
32+
"\n",
33+
"To run the colab locally you need install the\n",
34+
"`tensorflow`, `tensorflow-datasets` packages via `pip`."
3235
]
3336
},
3437
{

examples/cifar10_resnet.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"\n",
1111
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.sandbox.google.com/github/google-deepmind/optax/blob/main/examples/cifar10_resnet.ipynb)\n",
1212
"\n",
13-
"This notebook trains a residual network (ResNet) with optax on CIFAR10 or CIFAR100."
13+
"This notebook trains a residual network (ResNet) with optax on CIFAR10 or CIFAR100.\n",
14+
"\n",
15+
"To run the colab locally you need install the\n",
16+
"`tensorflow`, `tensorflow-datasets` packages via `pip`."
1417
]
1518
},
1619
{

examples/contrib/differentially_private_sgd.ipynb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"example in the [JAX repo](\n",
1515
"https://github.com/jax-ml/jax/blob/main/examples/differentially_private_sgd.py).\n",
1616
"\n",
17+
"To run the colab locally you need install the\n",
18+
"`dp-accounting`, `tensorflow`, `tensorflow-datasets`, packages via `pip`.\n",
19+
"\n",
20+
"\n",
1721
"[Differentially Private Stochastic Gradient Descent](https://arxiv.org/abs/1607.00133) requires clipping the per-example parameter\n",
1822
"gradients, which is non-trivial to implement efficiently for convolutional\n",
1923
"neural networks. The JAX XLA compiler shines in this setting by optimizing the\n",

examples/contrib/reduce_on_plateau.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"\n",
1111
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.sandbox.google.com/github/google-deepmind/optax/blob/main/examples/contrib/reduce_on_plateau.ipynb)\n",
1212
"\n",
13-
"In this notebook, we explore the power of {py:func}`optax.contrib.reduce_on_plateau` scheduler, that reduces the learning rate when a metric has stopped improving. We will be solving a classification task by training a simple Multilayer Perceptron (MLP) on the fashion MNIST dataset."
13+
"In this notebook, we explore the power of {py:func}`optax.contrib.reduce_on_plateau` scheduler, that reduces the learning rate when a metric has stopped improving. We will be solving a classification task by training a simple Multilayer Perceptron (MLP) on the fashion MNIST dataset.\n",
14+
"\n",
15+
"To run the colab locally you need install the\n",
16+
"`tensorflow`, `tensorflow-datasets` packages via `pip`."
1417
]
1518
},
1619
{

examples/lookahead_mnist.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"\n",
1111
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.sandbox.google.com/github/google-deepmind/optax/blob/main/examples/lookahead_mnist.ipynb)\n",
1212
"\n",
13-
"This notebook trains a simple Convolution Neural Network (CNN) for hand-written digit recognition (MNIST dataset) using {py:func}`optax.lookahead`."
13+
"This notebook trains a simple Convolution Neural Network (CNN) for hand-written digit recognition (MNIST dataset) using {py:func}`optax.lookahead`.\n",
14+
"\n",
15+
"To run the colab locally you need install the\n",
16+
"`tensorflow`, `tensorflow-datasets` packages via `pip`."
1417
]
1518
},
1619
{

examples/mlp_mnist.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"\n",
1111
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.sandbox.google.com/github/google-deepmind/optax/blob/main/examples/mlp_mnist.ipynb)\n",
1212
"\n",
13-
"This notebook trains a simple Multilayer Perceptron (MLP) classifier for hand-written digit recognition (MNIST dataset)."
13+
"This notebook trains a simple Multilayer Perceptron (MLP) classifier for hand-written digit recognition (MNIST dataset).\n",
14+
"\n",
15+
"To run the colab locally you need install the\n",
16+
"`tensorflow`, `tensorflow-datasets` packages via `pip`."
1417
]
1518
},
1619
{

pyproject.toml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,11 @@ documentation = "https://optax.readthedocs.io/"
4545

4646
[project.optional-dependencies]
4747
test = [
48-
"dm-tree>=0.1.7",
4948
"flax>=0.5.3",
5049
"scipy>=1.7.1",
5150
"scikit-learn"
5251
]
5352

54-
examples = [
55-
"tensorflow-datasets>=4.2.0",
56-
"tensorflow>=2.4.0",
57-
"dp_accounting>=0.4",
58-
"ipywidgets",
59-
"flax",
60-
]
61-
6253
docs = [
6354
"sphinx>=6.0.0",
6455
"sphinx-book-theme>=1.0.1", # Older versions fail to pin pydata-sphinx-theme
@@ -69,20 +60,10 @@ docs = [
6960
"matplotlib>=3.5.0",
7061
"sphinx-gallery>=0.14.0",
7162
"sphinx-collections>=0.0.1",
72-
"tensorflow>=2.4.0",
73-
"tensorflow-datasets>=4.2.0",
7463
"flax",
7564
"sphinx_contributors",
7665
]
7766

78-
dp-accounting = [
79-
"absl-py>=1.0.0",
80-
"attrs>=21.4.0",
81-
"mpmath>=1.2.1",
82-
"numpy>=1.21.4",
83-
"scipy>=1.7.1"
84-
]
85-
8667
[tool.setuptools.packages.find]
8768
include = ["README.md", "LICENSE"]
8869
exclude = ["*_test.py"]

test.sh

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,7 @@ pre-commit run -a
3838
# Install dependencies.
3939
python3 -m uv pip install --quiet --upgrade pip setuptools wheel
4040
python3 -m uv pip install --quiet --upgrade flake8 pytest-xdist pylint pylint-exit
41-
python3 -m uv pip install --quiet --editable ".[test, examples]"
42-
43-
# Dp-accounting specifies exact minor versions as requirements which sometimes
44-
# become incompatible with other libraries optax needs. We therefore install
45-
# dependencies for dp-accounting manually.
46-
# TODO(b/239416992): Remove this workaround if dp-accounting switches to minimum
47-
# version requirements.
48-
python3 -m uv pip install --quiet --editable ".[dp-accounting]"
49-
python3 -m uv pip install --quiet --no-deps "dp-accounting>=0.1.1"
41+
python3 -m uv pip install --quiet --editable ".[test]"
5042

5143
# Install the requested JAX version
5244
if [ -z "${JAX_VERSION-}" ]; then
@@ -89,16 +81,6 @@ cd "${REPO_DIR}"
8981

9082
# Build Sphinx docs.
9183
python3 -m uv pip install --quiet --editable ".[docs]"
92-
# NOTE(vroulet) We have dependencies issues:
93-
# tensorflow > 2.13.1 requires ml-dtypes <= 0.3.2
94-
# but jax requires ml-dtypes >= 0.4.0
95-
# So the environment is solved with tensorflow == 2.13.1 which requires
96-
# typing_extensions < 4.6, which in turn prevents the import of TypeAliasType in
97-
# IPython. We solve it here by simply upgrading typing_extensions to avoid that
98-
# bug (which issues conflict warnings but runs fine).
99-
# A long term solution is probably to fully remove tensorflow from our
100-
# dependencies.
101-
python3 -m uv pip install --upgrade --verbose typing_extensions
10284
cd docs
10385
make html
10486
make doctest # run doctests

0 commit comments

Comments
 (0)