optax 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {optax-0.2.2 → optax-0.2.4}/PKG-INFO +16 -12
- {optax-0.2.2 → optax-0.2.4}/README.md +6 -6
- {optax-0.2.2 → optax-0.2.4}/optax/__init__.py +103 -10
- {optax-0.2.2 → optax-0.2.4}/optax/_src/alias.py +1237 -518
- optax-0.2.4/optax/_src/alias_test.py +870 -0
- {optax-0.2.2 → optax-0.2.4}/optax/_src/base.py +41 -45
- {optax-0.2.2 → optax-0.2.4}/optax/_src/base_test.py +13 -12
- optax-0.2.4/optax/_src/clipping.py +31 -0
- optax-0.2.4/optax/_src/combine.py +22 -0
- {optax-0.2.2 → optax-0.2.4}/optax/_src/combine_test.py +36 -26
- optax-0.2.4/optax/_src/constrain.py +22 -0
- optax-0.2.4/optax/_src/deprecations.py +58 -0
- {optax-0.2.2 → optax-0.2.4}/optax/_src/factorized.py +79 -66
- optax-0.2.4/optax/_src/factorized_test.py +95 -0
- {optax-0.2.2 → optax-0.2.4}/optax/_src/float64_test.py +23 -15
- {optax-0.2.2 → optax-0.2.4}/optax/_src/linear_algebra.py +60 -50
- {optax-0.2.2 → optax-0.2.4}/optax/_src/linear_algebra_test.py +7 -10
- optax-0.2.4/optax/_src/linesearch.py +1636 -0
- optax-0.2.4/optax/_src/linesearch_test.py +684 -0
- {optax-0.2.2 → optax-0.2.4}/optax/_src/lookahead.py +52 -39
- {optax-0.2.2 → optax-0.2.4}/optax/_src/lookahead_test.py +30 -23
- {optax-0.2.2 → optax-0.2.4}/optax/_src/numerics.py +46 -19
- {optax-0.2.2 → optax-0.2.4}/optax/_src/numerics_test.py +81 -31
- {optax-0.2.2 → optax-0.2.4}/optax/_src/schedule.py +2 -1
- optax-0.2.4/optax/_src/transform.py +1798 -0
- optax-0.2.4/optax/_src/transform_test.py +225 -0
- {optax-0.2.2 → optax-0.2.4}/optax/_src/update.py +30 -23
- {optax-0.2.2 → optax-0.2.4}/optax/_src/update_test.py +33 -24
- {optax-0.2.2 → optax-0.2.4}/optax/_src/utils.py +44 -40
- {optax-0.2.2 → optax-0.2.4}/optax/_src/utils_test.py +5 -49
- optax-0.2.4/optax/_src/wrappers.py +60 -0
- optax-0.2.4/optax/assignment/__init__.py +19 -0
- optax-0.2.4/optax/assignment/_hungarian_algorithm.py +355 -0
- optax-0.2.4/optax/assignment/_hungarian_algorithm_test.py +125 -0
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/__init__.py +18 -0
- optax-0.2.4/optax/contrib/_acprop.py +160 -0
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_cocob.py +52 -16
- optax-0.2.4/optax/contrib/_common_test.py +358 -0
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_complex_valued.py +11 -9
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_complex_valued_test.py +8 -7
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_dadapt_adamw.py +29 -22
- optax-0.2.4/optax/contrib/_dog.py +339 -0
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_mechanic.py +52 -26
- optax-0.2.4/optax/contrib/_mechanic_test.py +109 -0
- optax-0.2.4/optax/contrib/_momo.py +353 -0
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_privacy.py +43 -35
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_privacy_test.py +32 -27
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_prodigy.py +39 -25
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_reduce_on_plateau.py +38 -23
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_reduce_on_plateau_test.py +52 -13
- {optax-0.2.2 → optax-0.2.4}/optax/contrib/_sam.py +65 -54
- optax-0.2.4/optax/contrib/_sam_test.py +105 -0
- optax-0.2.4/optax/contrib/_schedule_free.py +382 -0
- optax-0.2.4/optax/contrib/_schedule_free_test.py +155 -0
- {optax-0.2.2 → optax-0.2.4}/optax/losses/__init__.py +9 -0
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_classification.py +398 -119
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_classification_test.py +538 -122
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_fenchel_young.py +11 -12
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_fenchel_young_test.py +2 -2
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_ranking.py +2 -1
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_ranking_test.py +0 -1
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_regression.py +71 -52
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_regression_test.py +79 -34
- optax-0.2.4/optax/losses/_self_supervised.py +120 -0
- optax-0.2.4/optax/losses/_self_supervised_test.py +70 -0
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_smoothing.py +5 -4
- {optax-0.2.2 → optax-0.2.4}/optax/losses/_smoothing_test.py +24 -15
- {optax-0.2.2 → optax-0.2.4}/optax/monte_carlo/__init__.py +2 -0
- {optax-0.2.2 → optax-0.2.4}/optax/monte_carlo/control_variates.py +154 -115
- {optax-0.2.2 → optax-0.2.4}/optax/monte_carlo/control_variates_test.py +314 -158
- {optax-0.2.2 → optax-0.2.4}/optax/monte_carlo/stochastic_gradient_estimators.py +61 -26
- {optax-0.2.2 → optax-0.2.4}/optax/monte_carlo/stochastic_gradient_estimators_test.py +152 -95
- {optax-0.2.2 → optax-0.2.4}/optax/optax_test.py +3 -1
- optax-0.2.4/optax/perturbations/__init__.py +22 -0
- optax-0.2.4/optax/perturbations/_make_pert.py +195 -0
- optax-0.2.4/optax/perturbations/_make_pert_test.py +168 -0
- {optax-0.2.2 → optax-0.2.4}/optax/projections/__init__.py +8 -0
- optax-0.2.4/optax/projections/_projections.py +306 -0
- optax-0.2.4/optax/projections/_projections_test.py +227 -0
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/__init__.py +3 -0
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/_inject.py +42 -31
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/_inject_test.py +48 -38
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/_join.py +4 -3
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/_join_test.py +14 -14
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/_schedule.py +218 -101
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/_schedule_test.py +296 -135
- {optax-0.2.2 → optax-0.2.4}/optax/second_order/__init__.py +3 -1
- {optax-0.2.2 → optax-0.2.4}/optax/second_order/_fisher.py +5 -5
- {optax-0.2.2 → optax-0.2.4}/optax/second_order/_hessian.py +1 -2
- {optax-0.2.2 → optax-0.2.4}/optax/second_order/_hessian_test.py +5 -5
- optax-0.2.4/optax/transforms/__init__.py +94 -0
- optax-0.2.4/optax/transforms/_accumulation.py +422 -0
- optax-0.2.4/optax/transforms/_accumulation_test.py +383 -0
- optax-0.2.4/optax/transforms/_adding.py +111 -0
- optax-0.2.4/optax/transforms/_adding_test.py +112 -0
- optax-0.2.2/optax/_src/clipping.py → optax-0.2.4/optax/transforms/_clipping.py +128 -131
- optax-0.2.2/optax/_src/clipping_test.py → optax-0.2.4/optax/transforms/_clipping_test.py +51 -23
- optax-0.2.2/optax/_src/combine.py → optax-0.2.4/optax/transforms/_combining.py +116 -97
- optax-0.2.4/optax/transforms/_combining_test.py +292 -0
- optax-0.2.4/optax/transforms/_conditionality.py +272 -0
- optax-0.2.4/optax/transforms/_conditionality_test.py +293 -0
- optax-0.2.2/optax/_src/constrain.py → optax-0.2.4/optax/transforms/_constraining.py +24 -16
- optax-0.2.2/optax/_src/constrain_test.py → optax-0.2.4/optax/transforms/_constraining_test.py +80 -41
- optax-0.2.4/optax/transforms/_layouts.py +76 -0
- optax-0.2.4/optax/transforms/_layouts_test.py +59 -0
- optax-0.2.4/optax/transforms/_masking.py +149 -0
- optax-0.2.4/optax/transforms/_masking_test.py +395 -0
- {optax-0.2.2 → optax-0.2.4}/optax/tree_utils/__init__.py +16 -3
- optax-0.2.4/optax/tree_utils/_casting.py +214 -0
- optax-0.2.4/optax/tree_utils/_casting_test.py +107 -0
- optax-0.2.4/optax/tree_utils/_random.py +75 -0
- optax-0.2.4/optax/tree_utils/_random_test.py +110 -0
- {optax-0.2.2 → optax-0.2.4}/optax/tree_utils/_state_utils.py +73 -72
- {optax-0.2.2 → optax-0.2.4}/optax/tree_utils/_state_utils_test.py +8 -12
- optax-0.2.4/optax/tree_utils/_tree_math.py +376 -0
- optax-0.2.4/optax/tree_utils/_tree_math_test.py +296 -0
- {optax-0.2.2 → optax-0.2.4}/pyproject.toml +10 -5
- optax-0.2.2/optax/_src/alias_test.py +0 -207
- optax-0.2.2/optax/_src/factorized_test.py +0 -50
- optax-0.2.2/optax/_src/linesearch.py +0 -367
- optax-0.2.2/optax/_src/linesearch_test.py +0 -262
- optax-0.2.2/optax/_src/transform.py +0 -1464
- optax-0.2.2/optax/_src/transform_test.py +0 -336
- optax-0.2.2/optax/_src/wrappers.py +0 -612
- optax-0.2.2/optax/_src/wrappers_test.py +0 -771
- optax-0.2.2/optax/contrib/_common_test.py +0 -125
- optax-0.2.2/optax/contrib/_mechanic_test.py +0 -194
- optax-0.2.2/optax/contrib/_sam_test.py +0 -202
- optax-0.2.2/optax/projections/_projections.py +0 -90
- optax-0.2.2/optax/projections/_projections_test.py +0 -98
- optax-0.2.2/optax/tree_utils/_tree_math.py +0 -253
- optax-0.2.2/optax/tree_utils/_tree_math_test.py +0 -201
- {optax-0.2.2 → optax-0.2.4}/LICENSE +0 -0
- {optax-0.2.2 → optax-0.2.4}/optax/schedules/inject.py +0 -0
- {optax-0.2.2 → optax-0.2.4}/optax/second_order/_base.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: optax
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: A gradient processing and
|
|
3
|
+
Version: 0.2.4
|
|
4
|
+
Summary: A gradient processing and optimization library in JAX.
|
|
5
5
|
Keywords: python,machine learning,reinforcement-learning
|
|
6
6
|
Author-email: Google DeepMind <optax-dev@google.com>
|
|
7
7
|
Requires-Python: >=3.9
|
|
@@ -17,10 +17,11 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
17
17
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
19
|
Requires-Dist: absl-py>=0.7.1
|
|
20
|
-
Requires-Dist: chex>=0.1.
|
|
21
|
-
Requires-Dist: jax>=0.
|
|
22
|
-
Requires-Dist: jaxlib>=0.
|
|
20
|
+
Requires-Dist: chex>=0.1.87
|
|
21
|
+
Requires-Dist: jax>=0.4.27
|
|
22
|
+
Requires-Dist: jaxlib>=0.4.27
|
|
23
23
|
Requires-Dist: numpy>=1.18.0
|
|
24
|
+
Requires-Dist: etils[epy]
|
|
24
25
|
Requires-Dist: sphinx>=6.0.0 ; extra == "docs"
|
|
25
26
|
Requires-Dist: sphinx-book-theme>=1.0.1 ; extra == "docs"
|
|
26
27
|
Requires-Dist: sphinxcontrib-katex ; extra == "docs"
|
|
@@ -42,9 +43,12 @@ Requires-Dist: scipy>=1.7.1 ; extra == "dp-accounting"
|
|
|
42
43
|
Requires-Dist: tensorflow-datasets>=4.2.0 ; extra == "examples"
|
|
43
44
|
Requires-Dist: tensorflow>=2.4.0 ; extra == "examples"
|
|
44
45
|
Requires-Dist: dp_accounting>=0.4 ; extra == "examples"
|
|
46
|
+
Requires-Dist: ipywidgets ; extra == "examples"
|
|
45
47
|
Requires-Dist: flax ; extra == "examples"
|
|
46
48
|
Requires-Dist: dm-tree>=0.1.7 ; extra == "test"
|
|
47
49
|
Requires-Dist: flax>=0.5.3 ; extra == "test"
|
|
50
|
+
Requires-Dist: scipy>=1.7.1 ; extra == "test"
|
|
51
|
+
Requires-Dist: scikit-learn ; extra == "test"
|
|
48
52
|
Project-URL: documentation, https://optax.readthedocs.io/
|
|
49
53
|
Project-URL: homepage, https://github.com/google-deepmind/optax
|
|
50
54
|
Project-URL: repository, https://github.com/google-deepmind/optax
|
|
@@ -70,12 +74,12 @@ Our goals are to
|
|
|
70
74
|
|
|
71
75
|
* Provide simple, well-tested, efficient implementations of core components.
|
|
72
76
|
* Improve research productivity by enabling to easily combine low-level
|
|
73
|
-
ingredients into custom
|
|
77
|
+
ingredients into custom optimizers (or other gradient processing components).
|
|
74
78
|
* Accelerate adoption of new ideas by making it easy for anyone to contribute.
|
|
75
79
|
|
|
76
|
-
We
|
|
80
|
+
We favor focusing on small composable building blocks that can be effectively
|
|
77
81
|
combined into custom solutions. Others may build upon these basic components
|
|
78
|
-
in more complicated abstractions. Whenever reasonable, implementations
|
|
82
|
+
in more complicated abstractions. Whenever reasonable, implementations prioritize
|
|
79
83
|
readability and structuring code to match standard equations, over code reuse.
|
|
80
84
|
|
|
81
85
|
An initial prototype of this library was made available in JAX's experimental
|
|
@@ -132,7 +136,7 @@ updates, opt_state = optimizer.update(grads, opt_state)
|
|
|
132
136
|
params = optax.apply_updates(params, updates)
|
|
133
137
|
```
|
|
134
138
|
|
|
135
|
-
You can continue the quick start in [the Optax
|
|
139
|
+
You can continue the quick start in [the Optax 🚀 Getting started notebook.](https://github.com/google-deepmind/optax/blob/main/docs/getting_started.ipynb)
|
|
136
140
|
|
|
137
141
|
## Development
|
|
138
142
|
|
|
@@ -150,7 +154,7 @@ git clone https://github.com/google-deepmind/optax.git
|
|
|
150
154
|
To run the tests, please execute the following script.
|
|
151
155
|
|
|
152
156
|
```sh
|
|
153
|
-
sh
|
|
157
|
+
sh test.sh
|
|
154
158
|
```
|
|
155
159
|
|
|
156
160
|
### Documentation
|
|
@@ -161,7 +165,7 @@ pip install -e ".[docs]"
|
|
|
161
165
|
```
|
|
162
166
|
Then, execute the following.
|
|
163
167
|
```sh
|
|
164
|
-
cd docs
|
|
168
|
+
cd docs
|
|
165
169
|
make html
|
|
166
170
|
```
|
|
167
171
|
|
|
@@ -15,12 +15,12 @@ Our goals are to
|
|
|
15
15
|
|
|
16
16
|
* Provide simple, well-tested, efficient implementations of core components.
|
|
17
17
|
* Improve research productivity by enabling to easily combine low-level
|
|
18
|
-
ingredients into custom
|
|
18
|
+
ingredients into custom optimizers (or other gradient processing components).
|
|
19
19
|
* Accelerate adoption of new ideas by making it easy for anyone to contribute.
|
|
20
20
|
|
|
21
|
-
We
|
|
21
|
+
We favor focusing on small composable building blocks that can be effectively
|
|
22
22
|
combined into custom solutions. Others may build upon these basic components
|
|
23
|
-
in more complicated abstractions. Whenever reasonable, implementations
|
|
23
|
+
in more complicated abstractions. Whenever reasonable, implementations prioritize
|
|
24
24
|
readability and structuring code to match standard equations, over code reuse.
|
|
25
25
|
|
|
26
26
|
An initial prototype of this library was made available in JAX's experimental
|
|
@@ -77,7 +77,7 @@ updates, opt_state = optimizer.update(grads, opt_state)
|
|
|
77
77
|
params = optax.apply_updates(params, updates)
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
You can continue the quick start in [the Optax
|
|
80
|
+
You can continue the quick start in [the Optax 🚀 Getting started notebook.](https://github.com/google-deepmind/optax/blob/main/docs/getting_started.ipynb)
|
|
81
81
|
|
|
82
82
|
## Development
|
|
83
83
|
|
|
@@ -95,7 +95,7 @@ git clone https://github.com/google-deepmind/optax.git
|
|
|
95
95
|
To run the tests, please execute the following script.
|
|
96
96
|
|
|
97
97
|
```sh
|
|
98
|
-
sh
|
|
98
|
+
sh test.sh
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
### Documentation
|
|
@@ -106,7 +106,7 @@ pip install -e ".[docs]"
|
|
|
106
106
|
```
|
|
107
107
|
Then, execute the following.
|
|
108
108
|
```sh
|
|
109
|
-
cd docs
|
|
109
|
+
cd docs
|
|
110
110
|
make html
|
|
111
111
|
```
|
|
112
112
|
|
|
@@ -14,12 +14,18 @@
|
|
|
14
14
|
# ==============================================================================
|
|
15
15
|
"""Optax: composable gradient processing and optimization, in JAX."""
|
|
16
16
|
|
|
17
|
+
# pylint: disable=wrong-import-position
|
|
18
|
+
# pylint: disable=g-importing-member
|
|
19
|
+
|
|
20
|
+
from optax import assignment
|
|
17
21
|
from optax import contrib
|
|
18
22
|
from optax import losses
|
|
19
23
|
from optax import monte_carlo
|
|
24
|
+
from optax import perturbations
|
|
20
25
|
from optax import projections
|
|
21
26
|
from optax import schedules
|
|
22
27
|
from optax import second_order
|
|
28
|
+
from optax import transforms
|
|
23
29
|
from optax import tree_utils
|
|
24
30
|
from optax._src.alias import adabelief
|
|
25
31
|
from optax._src.alias import adadelta
|
|
@@ -29,22 +35,26 @@ from optax._src.alias import adam
|
|
|
29
35
|
from optax._src.alias import adamax
|
|
30
36
|
from optax._src.alias import adamaxw
|
|
31
37
|
from optax._src.alias import adamw
|
|
38
|
+
from optax._src.alias import adan
|
|
32
39
|
from optax._src.alias import amsgrad
|
|
33
40
|
from optax._src.alias import fromage
|
|
34
41
|
from optax._src.alias import lamb
|
|
35
42
|
from optax._src.alias import lars
|
|
43
|
+
from optax._src.alias import lbfgs
|
|
36
44
|
from optax._src.alias import lion
|
|
37
45
|
from optax._src.alias import MaskOrFn
|
|
38
46
|
from optax._src.alias import nadam
|
|
39
47
|
from optax._src.alias import nadamw
|
|
40
48
|
from optax._src.alias import noisy_sgd
|
|
41
49
|
from optax._src.alias import novograd
|
|
50
|
+
from optax._src.alias import optimistic_adam
|
|
42
51
|
from optax._src.alias import optimistic_gradient_descent
|
|
43
52
|
from optax._src.alias import polyak_sgd
|
|
44
53
|
from optax._src.alias import radam
|
|
45
54
|
from optax._src.alias import rmsprop
|
|
46
55
|
from optax._src.alias import rprop
|
|
47
56
|
from optax._src.alias import sgd
|
|
57
|
+
from optax._src.alias import sign_sgd
|
|
48
58
|
from optax._src.alias import sm3
|
|
49
59
|
from optax._src.alias import yogi
|
|
50
60
|
from optax._src.base import EmptyState
|
|
@@ -86,10 +96,14 @@ from optax._src.linear_algebra import global_norm
|
|
|
86
96
|
from optax._src.linear_algebra import matrix_inverse_pth_root
|
|
87
97
|
from optax._src.linear_algebra import power_iteration
|
|
88
98
|
from optax._src.linesearch import scale_by_backtracking_linesearch
|
|
99
|
+
from optax._src.linesearch import scale_by_zoom_linesearch
|
|
89
100
|
from optax._src.linesearch import ScaleByBacktrackingLinesearchState
|
|
101
|
+
from optax._src.linesearch import ScaleByZoomLinesearchState
|
|
102
|
+
from optax._src.linesearch import ZoomLinesearchInfo
|
|
90
103
|
from optax._src.lookahead import lookahead
|
|
91
104
|
from optax._src.lookahead import LookaheadParams
|
|
92
105
|
from optax._src.lookahead import LookaheadState
|
|
106
|
+
from optax._src.numerics import safe_increment
|
|
93
107
|
from optax._src.numerics import safe_int32_increment
|
|
94
108
|
from optax._src.numerics import safe_norm
|
|
95
109
|
from optax._src.numerics import safe_root_mean_squares
|
|
@@ -99,17 +113,19 @@ from optax._src.transform import AddDecayedWeightsState
|
|
|
99
113
|
from optax._src.transform import AddNoiseState
|
|
100
114
|
from optax._src.transform import apply_every
|
|
101
115
|
from optax._src.transform import ApplyEvery
|
|
102
|
-
from optax._src.transform import bias_correction
|
|
103
116
|
from optax._src.transform import centralize
|
|
104
117
|
from optax._src.transform import ema
|
|
105
118
|
from optax._src.transform import EmaState
|
|
119
|
+
from optax._src.transform import normalize_by_update_norm
|
|
106
120
|
from optax._src.transform import scale
|
|
107
121
|
from optax._src.transform import scale_by_adadelta
|
|
108
122
|
from optax._src.transform import scale_by_adam
|
|
109
123
|
from optax._src.transform import scale_by_adamax
|
|
124
|
+
from optax._src.transform import scale_by_adan
|
|
110
125
|
from optax._src.transform import scale_by_amsgrad
|
|
111
126
|
from optax._src.transform import scale_by_belief
|
|
112
127
|
from optax._src.transform import scale_by_distance_over_gradients
|
|
128
|
+
from optax._src.transform import scale_by_lbfgs
|
|
113
129
|
from optax._src.transform import scale_by_learning_rate
|
|
114
130
|
from optax._src.transform import scale_by_lion
|
|
115
131
|
from optax._src.transform import scale_by_novograd
|
|
@@ -122,14 +138,17 @@ from optax._src.transform import scale_by_rms
|
|
|
122
138
|
from optax._src.transform import scale_by_rprop
|
|
123
139
|
from optax._src.transform import scale_by_rss
|
|
124
140
|
from optax._src.transform import scale_by_schedule
|
|
141
|
+
from optax._src.transform import scale_by_sign
|
|
125
142
|
from optax._src.transform import scale_by_sm3
|
|
126
143
|
from optax._src.transform import scale_by_stddev
|
|
127
144
|
from optax._src.transform import scale_by_trust_ratio
|
|
128
145
|
from optax._src.transform import scale_by_yogi
|
|
129
146
|
from optax._src.transform import ScaleByAdaDeltaState
|
|
130
147
|
from optax._src.transform import ScaleByAdamState
|
|
148
|
+
from optax._src.transform import ScaleByAdanState
|
|
131
149
|
from optax._src.transform import ScaleByAmsgradState
|
|
132
150
|
from optax._src.transform import ScaleByBeliefState
|
|
151
|
+
from optax._src.transform import ScaleByLBFGSState
|
|
133
152
|
from optax._src.transform import ScaleByLionState
|
|
134
153
|
from optax._src.transform import ScaleByNovogradState
|
|
135
154
|
from optax._src.transform import ScaleByRmsState
|
|
@@ -142,9 +161,6 @@ from optax._src.transform import ScaleByTrustRatioState
|
|
|
142
161
|
from optax._src.transform import ScaleState
|
|
143
162
|
from optax._src.transform import trace
|
|
144
163
|
from optax._src.transform import TraceState
|
|
145
|
-
from optax._src.transform import update_infinity_moment
|
|
146
|
-
from optax._src.transform import update_moment
|
|
147
|
-
from optax._src.transform import update_moment_per_elem_norm
|
|
148
164
|
from optax._src.update import apply_updates
|
|
149
165
|
from optax._src.update import incremental_update
|
|
150
166
|
from optax._src.update import periodic_update
|
|
@@ -153,6 +169,10 @@ from optax._src.utils import scale_gradient
|
|
|
153
169
|
from optax._src.utils import value_and_grad_from_state
|
|
154
170
|
from optax._src.wrappers import apply_if_finite
|
|
155
171
|
from optax._src.wrappers import ApplyIfFiniteState
|
|
172
|
+
from optax._src.wrappers import conditionally_mask
|
|
173
|
+
from optax._src.wrappers import conditionally_transform
|
|
174
|
+
from optax._src.wrappers import ConditionallyMaskState
|
|
175
|
+
from optax._src.wrappers import ConditionallyTransformState
|
|
156
176
|
from optax._src.wrappers import flatten
|
|
157
177
|
from optax._src.wrappers import masked
|
|
158
178
|
from optax._src.wrappers import MaskedNode
|
|
@@ -165,8 +185,13 @@ from optax._src.wrappers import ShouldSkipUpdateFunction
|
|
|
165
185
|
from optax._src.wrappers import skip_large_updates
|
|
166
186
|
from optax._src.wrappers import skip_not_finite
|
|
167
187
|
|
|
188
|
+
|
|
168
189
|
# TODO(mtthss): remove tree_utils aliases after updates.
|
|
169
190
|
tree_map_params = tree_utils.tree_map_params
|
|
191
|
+
bias_correction = tree_utils.tree_bias_correction
|
|
192
|
+
update_infinity_moment = tree_utils.tree_update_infinity_moment
|
|
193
|
+
update_moment = tree_utils.tree_update_moment
|
|
194
|
+
update_moment_per_elem_norm = tree_utils.tree_update_moment_per_elem_norm
|
|
170
195
|
|
|
171
196
|
# TODO(mtthss): remove schedules alises from flat namespaces after user updates.
|
|
172
197
|
constant_schedule = schedules.constant_schedule
|
|
@@ -182,6 +207,7 @@ piecewise_constant_schedule = schedules.piecewise_constant_schedule
|
|
|
182
207
|
piecewise_interpolate_schedule = schedules.piecewise_interpolate_schedule
|
|
183
208
|
polynomial_schedule = schedules.polynomial_schedule
|
|
184
209
|
sgdr_schedule = schedules.sgdr_schedule
|
|
210
|
+
warmup_constant_schedule = schedules.warmup_constant_schedule
|
|
185
211
|
warmup_cosine_decay_schedule = schedules.warmup_cosine_decay_schedule
|
|
186
212
|
warmup_exponential_decay_schedule = schedules.warmup_exponential_decay_schedule
|
|
187
213
|
inject_stateful_hyperparams = schedules.inject_stateful_hyperparams
|
|
@@ -199,8 +225,10 @@ huber_loss = losses.huber_loss
|
|
|
199
225
|
kl_divergence = losses.kl_divergence
|
|
200
226
|
l2_loss = losses.l2_loss
|
|
201
227
|
log_cosh = losses.log_cosh
|
|
228
|
+
ntxent = losses.ntxent
|
|
202
229
|
sigmoid_binary_cross_entropy = losses.sigmoid_binary_cross_entropy
|
|
203
230
|
smooth_labels = losses.smooth_labels
|
|
231
|
+
safe_softmax_cross_entropy = losses.safe_softmax_cross_entropy
|
|
204
232
|
softmax_cross_entropy = losses.softmax_cross_entropy
|
|
205
233
|
softmax_cross_entropy_with_integer_labels = (
|
|
206
234
|
losses.softmax_cross_entropy_with_integer_labels
|
|
@@ -208,14 +236,61 @@ softmax_cross_entropy_with_integer_labels = (
|
|
|
208
236
|
squared_error = losses.squared_error
|
|
209
237
|
sigmoid_focal_loss = losses.sigmoid_focal_loss
|
|
210
238
|
|
|
239
|
+
# pylint: disable=g-import-not-at-top
|
|
211
240
|
# TODO(mtthss): remove contrib aliases from flat namespace once users updated.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
241
|
+
# Deprecated modules
|
|
242
|
+
from optax.contrib import differentially_private_aggregate as _deprecated_differentially_private_aggregate
|
|
243
|
+
from optax.contrib import DifferentiallyPrivateAggregateState as _deprecated_DifferentiallyPrivateAggregateState
|
|
244
|
+
from optax.contrib import dpsgd as _deprecated_dpsgd
|
|
245
|
+
|
|
246
|
+
_deprecations = {
|
|
247
|
+
# Added Apr 2024
|
|
248
|
+
"differentially_private_aggregate": (
|
|
249
|
+
(
|
|
250
|
+
"optax.differentially_private_aggregate is deprecated: use"
|
|
251
|
+
" optax.contrib.differentially_private_aggregate (optax v0.1.8 or"
|
|
252
|
+
" newer)."
|
|
253
|
+
),
|
|
254
|
+
_deprecated_differentially_private_aggregate,
|
|
255
|
+
),
|
|
256
|
+
"DifferentiallyPrivateAggregateState": (
|
|
257
|
+
(
|
|
258
|
+
"optax.DifferentiallyPrivateAggregateState is deprecated: use"
|
|
259
|
+
" optax.contrib.DifferentiallyPrivateAggregateState (optax v0.1.8"
|
|
260
|
+
" or newer)."
|
|
261
|
+
),
|
|
262
|
+
_deprecated_DifferentiallyPrivateAggregateState,
|
|
263
|
+
),
|
|
264
|
+
"dpsgd": (
|
|
265
|
+
(
|
|
266
|
+
"optax.dpsgd is deprecated: use optax.contrib.dpsgd (optax v0.1.8"
|
|
267
|
+
" or newer)."
|
|
268
|
+
),
|
|
269
|
+
_deprecated_dpsgd,
|
|
270
|
+
),
|
|
271
|
+
}
|
|
272
|
+
# pylint: disable=g-bad-import-order
|
|
273
|
+
import typing as _typing
|
|
274
|
+
|
|
275
|
+
if _typing.TYPE_CHECKING:
|
|
276
|
+
# pylint: disable=reimported
|
|
277
|
+
from optax.contrib import differentially_private_aggregate
|
|
278
|
+
from optax.contrib import DifferentiallyPrivateAggregateState
|
|
279
|
+
from optax.contrib import dpsgd
|
|
280
|
+
# pylint: enable=reimported
|
|
281
|
+
|
|
282
|
+
else:
|
|
283
|
+
from optax._src.deprecations import deprecation_getattr as _deprecation_getattr
|
|
284
|
+
|
|
285
|
+
__getattr__ = _deprecation_getattr(__name__, _deprecations)
|
|
286
|
+
del _deprecation_getattr
|
|
287
|
+
del _typing
|
|
288
|
+
# pylint: enable=g-bad-import-order
|
|
289
|
+
# pylint: enable=g-import-not-at-top
|
|
290
|
+
# pylint: enable=g-importing-member
|
|
291
|
+
|
|
217
292
|
|
|
218
|
-
__version__ = "0.2.
|
|
293
|
+
__version__ = "0.2.4"
|
|
219
294
|
|
|
220
295
|
__all__ = (
|
|
221
296
|
"adabelief",
|
|
@@ -226,6 +301,7 @@ __all__ = (
|
|
|
226
301
|
"adamax",
|
|
227
302
|
"adamaxw",
|
|
228
303
|
"adamw",
|
|
304
|
+
"adan",
|
|
229
305
|
"adaptive_grad_clip",
|
|
230
306
|
"AdaptiveGradClipState",
|
|
231
307
|
"add_decayed_weights",
|
|
@@ -238,6 +314,7 @@ __all__ = (
|
|
|
238
314
|
"apply_updates",
|
|
239
315
|
"ApplyEvery",
|
|
240
316
|
"ApplyIfFiniteState",
|
|
317
|
+
"assignment",
|
|
241
318
|
"centralize",
|
|
242
319
|
"chain",
|
|
243
320
|
"clip_by_block_rms",
|
|
@@ -245,6 +322,10 @@ __all__ = (
|
|
|
245
322
|
"clip",
|
|
246
323
|
"ClipByGlobalNormState",
|
|
247
324
|
"ClipState",
|
|
325
|
+
"conditionally_mask",
|
|
326
|
+
"ConditionallyMaskState",
|
|
327
|
+
"conditionally_transform",
|
|
328
|
+
"ConditionallyTransformState",
|
|
248
329
|
"constant_schedule",
|
|
249
330
|
"ctc_loss",
|
|
250
331
|
"ctc_loss_with_forward_probs",
|
|
@@ -278,6 +359,7 @@ __all__ = (
|
|
|
278
359
|
"l2_loss",
|
|
279
360
|
"lamb",
|
|
280
361
|
"lars",
|
|
362
|
+
"lbfgs",
|
|
281
363
|
"lion",
|
|
282
364
|
"linear_onecycle_schedule",
|
|
283
365
|
"linear_schedule",
|
|
@@ -301,6 +383,7 @@ __all__ = (
|
|
|
301
383
|
"noisy_sgd",
|
|
302
384
|
"novograd",
|
|
303
385
|
"NonNegativeParamsState",
|
|
386
|
+
"ntxent",
|
|
304
387
|
"OptState",
|
|
305
388
|
"Params",
|
|
306
389
|
"periodic_update",
|
|
@@ -314,6 +397,7 @@ __all__ = (
|
|
|
314
397
|
"radam",
|
|
315
398
|
"rmsprop",
|
|
316
399
|
"rprop",
|
|
400
|
+
"safe_increment",
|
|
317
401
|
"safe_int32_increment",
|
|
318
402
|
"safe_norm",
|
|
319
403
|
"safe_root_mean_squares",
|
|
@@ -321,9 +405,11 @@ __all__ = (
|
|
|
321
405
|
"scale_by_adadelta",
|
|
322
406
|
"scale_by_adam",
|
|
323
407
|
"scale_by_adamax",
|
|
408
|
+
"scale_by_adan",
|
|
324
409
|
"scale_by_amsgrad",
|
|
325
410
|
"scale_by_backtracking_linesearch",
|
|
326
411
|
"scale_by_belief",
|
|
412
|
+
"scale_by_lbfgs",
|
|
327
413
|
"scale_by_lion",
|
|
328
414
|
"scale_by_factored_rms",
|
|
329
415
|
"scale_by_novograd",
|
|
@@ -335,17 +421,21 @@ __all__ = (
|
|
|
335
421
|
"scale_by_rprop",
|
|
336
422
|
"scale_by_rss",
|
|
337
423
|
"scale_by_schedule",
|
|
424
|
+
"scale_by_sign",
|
|
338
425
|
"scale_by_sm3",
|
|
339
426
|
"scale_by_stddev",
|
|
340
427
|
"scale_by_trust_ratio",
|
|
341
428
|
"scale_by_yogi",
|
|
429
|
+
"scale_by_zoom_linesearch",
|
|
342
430
|
"scale_gradient",
|
|
343
431
|
"scale",
|
|
344
432
|
"ScaleByAdaDeltaState",
|
|
345
433
|
"ScaleByAdamState",
|
|
434
|
+
"ScaleByAdanState",
|
|
346
435
|
"ScaleByAmsgradState",
|
|
347
436
|
"ScaleByBacktrackingLinesearchState",
|
|
348
437
|
"ScaleByBeliefState",
|
|
438
|
+
"ScaleByLBFGSState",
|
|
349
439
|
"ScaleByLionState",
|
|
350
440
|
"ScaleByNovogradState",
|
|
351
441
|
"ScaleByRmsState",
|
|
@@ -355,6 +445,7 @@ __all__ = (
|
|
|
355
445
|
"ScaleByScheduleState",
|
|
356
446
|
"ScaleBySM3State",
|
|
357
447
|
"ScaleByTrustRatioState",
|
|
448
|
+
"ScaleByZoomLinesearchState",
|
|
358
449
|
"ScaleState",
|
|
359
450
|
"Schedule",
|
|
360
451
|
"set_to_zero",
|
|
@@ -362,6 +453,7 @@ __all__ = (
|
|
|
362
453
|
"sgdr_schedule",
|
|
363
454
|
"ShouldSkipUpdateFunction",
|
|
364
455
|
"sigmoid_binary_cross_entropy",
|
|
456
|
+
"sign_sgd",
|
|
365
457
|
"skip_large_updates",
|
|
366
458
|
"skip_not_finite",
|
|
367
459
|
"sm3",
|
|
@@ -382,6 +474,7 @@ __all__ = (
|
|
|
382
474
|
"yogi",
|
|
383
475
|
"zero_nans",
|
|
384
476
|
"ZeroNansState",
|
|
477
|
+
"ZoomLinesearchInfo",
|
|
385
478
|
)
|
|
386
479
|
|
|
387
480
|
# _________________________________________
|