optax 0.2.3__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.
Files changed (128) hide show
  1. {optax-0.2.3 → optax-0.2.4}/PKG-INFO +9 -9
  2. {optax-0.2.3 → optax-0.2.4}/README.md +5 -5
  3. {optax-0.2.3 → optax-0.2.4}/optax/__init__.py +18 -1
  4. {optax-0.2.3 → optax-0.2.4}/optax/_src/alias.py +1062 -554
  5. {optax-0.2.3 → optax-0.2.4}/optax/_src/alias_test.py +156 -69
  6. {optax-0.2.3 → optax-0.2.4}/optax/_src/base.py +31 -28
  7. {optax-0.2.3 → optax-0.2.4}/optax/_src/base_test.py +13 -12
  8. {optax-0.2.3 → optax-0.2.4}/optax/_src/combine_test.py +36 -26
  9. {optax-0.2.3 → optax-0.2.4}/optax/_src/factorized.py +79 -66
  10. optax-0.2.4/optax/_src/factorized_test.py +95 -0
  11. {optax-0.2.3 → optax-0.2.4}/optax/_src/float64_test.py +23 -15
  12. {optax-0.2.3 → optax-0.2.4}/optax/_src/linear_algebra.py +60 -50
  13. {optax-0.2.3 → optax-0.2.4}/optax/_src/linear_algebra_test.py +5 -8
  14. {optax-0.2.3 → optax-0.2.4}/optax/_src/linesearch.py +299 -204
  15. {optax-0.2.3 → optax-0.2.4}/optax/_src/linesearch_test.py +29 -20
  16. {optax-0.2.3 → optax-0.2.4}/optax/_src/lookahead.py +23 -20
  17. {optax-0.2.3 → optax-0.2.4}/optax/_src/lookahead_test.py +27 -20
  18. {optax-0.2.3 → optax-0.2.4}/optax/_src/numerics.py +46 -19
  19. {optax-0.2.3 → optax-0.2.4}/optax/_src/numerics_test.py +81 -31
  20. {optax-0.2.3 → optax-0.2.4}/optax/_src/schedule.py +1 -1
  21. {optax-0.2.3 → optax-0.2.4}/optax/_src/transform.py +524 -289
  22. {optax-0.2.3 → optax-0.2.4}/optax/_src/transform_test.py +71 -37
  23. {optax-0.2.3 → optax-0.2.4}/optax/_src/update.py +30 -23
  24. {optax-0.2.3 → optax-0.2.4}/optax/_src/update_test.py +33 -24
  25. {optax-0.2.3 → optax-0.2.4}/optax/_src/utils.py +36 -35
  26. {optax-0.2.3 → optax-0.2.4}/optax/_src/utils_test.py +5 -30
  27. {optax-0.2.3 → optax-0.2.4}/optax/_src/wrappers.py +6 -5
  28. optax-0.2.4/optax/assignment/__init__.py +19 -0
  29. optax-0.2.4/optax/assignment/_hungarian_algorithm.py +355 -0
  30. optax-0.2.4/optax/assignment/_hungarian_algorithm_test.py +125 -0
  31. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_acprop.py +13 -15
  32. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_cocob.py +18 -19
  33. optax-0.2.4/optax/contrib/_common_test.py +358 -0
  34. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_complex_valued.py +11 -9
  35. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_complex_valued_test.py +8 -7
  36. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_dadapt_adamw.py +29 -22
  37. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_dog.py +58 -63
  38. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_mechanic.py +52 -27
  39. optax-0.2.4/optax/contrib/_mechanic_test.py +109 -0
  40. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_momo.py +79 -69
  41. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_privacy.py +43 -35
  42. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_privacy_test.py +32 -27
  43. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_prodigy.py +30 -24
  44. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_reduce_on_plateau.py +19 -17
  45. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_reduce_on_plateau_test.py +15 -11
  46. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_sam.py +65 -55
  47. optax-0.2.3/optax/contrib/_schedule_free_test.py → optax-0.2.4/optax/contrib/_sam_test.py +43 -48
  48. {optax-0.2.3 → optax-0.2.4}/optax/contrib/_schedule_free.py +93 -62
  49. optax-0.2.4/optax/contrib/_schedule_free_test.py +155 -0
  50. {optax-0.2.3 → optax-0.2.4}/optax/losses/_classification.py +253 -137
  51. {optax-0.2.3 → optax-0.2.4}/optax/losses/_classification_test.py +144 -9
  52. {optax-0.2.3 → optax-0.2.4}/optax/losses/_fenchel_young.py +11 -12
  53. {optax-0.2.3 → optax-0.2.4}/optax/losses/_fenchel_young_test.py +2 -2
  54. {optax-0.2.3 → optax-0.2.4}/optax/losses/_ranking.py +2 -1
  55. {optax-0.2.3 → optax-0.2.4}/optax/losses/_ranking_test.py +0 -1
  56. {optax-0.2.3 → optax-0.2.4}/optax/losses/_regression.py +71 -52
  57. {optax-0.2.3 → optax-0.2.4}/optax/losses/_regression_test.py +79 -34
  58. {optax-0.2.3 → optax-0.2.4}/optax/losses/_self_supervised.py +39 -7
  59. {optax-0.2.3 → optax-0.2.4}/optax/losses/_self_supervised_test.py +14 -1
  60. {optax-0.2.3 → optax-0.2.4}/optax/losses/_smoothing.py +5 -4
  61. {optax-0.2.3 → optax-0.2.4}/optax/losses/_smoothing_test.py +24 -15
  62. {optax-0.2.3 → optax-0.2.4}/optax/monte_carlo/__init__.py +2 -0
  63. {optax-0.2.3 → optax-0.2.4}/optax/monte_carlo/control_variates.py +140 -102
  64. {optax-0.2.3 → optax-0.2.4}/optax/monte_carlo/control_variates_test.py +314 -160
  65. {optax-0.2.3 → optax-0.2.4}/optax/monte_carlo/stochastic_gradient_estimators.py +61 -26
  66. {optax-0.2.3 → optax-0.2.4}/optax/monte_carlo/stochastic_gradient_estimators_test.py +152 -95
  67. {optax-0.2.3 → optax-0.2.4}/optax/optax_test.py +1 -2
  68. optax-0.2.4/optax/perturbations/__init__.py +22 -0
  69. optax-0.2.4/optax/perturbations/_make_pert.py +195 -0
  70. optax-0.2.4/optax/perturbations/_make_pert_test.py +168 -0
  71. {optax-0.2.3 → optax-0.2.4}/optax/projections/__init__.py +7 -0
  72. optax-0.2.4/optax/projections/_projections.py +306 -0
  73. {optax-0.2.3 → optax-0.2.4}/optax/projections/_projections_test.py +58 -3
  74. {optax-0.2.3 → optax-0.2.4}/optax/schedules/__init__.py +2 -0
  75. {optax-0.2.3 → optax-0.2.4}/optax/schedules/_inject.py +6 -5
  76. {optax-0.2.3 → optax-0.2.4}/optax/schedules/_inject_test.py +48 -38
  77. {optax-0.2.3 → optax-0.2.4}/optax/schedules/_join.py +4 -3
  78. {optax-0.2.3 → optax-0.2.4}/optax/schedules/_join_test.py +14 -14
  79. {optax-0.2.3 → optax-0.2.4}/optax/schedules/_schedule.py +195 -101
  80. {optax-0.2.3 → optax-0.2.4}/optax/schedules/_schedule_test.py +296 -135
  81. {optax-0.2.3 → optax-0.2.4}/optax/second_order/__init__.py +3 -1
  82. {optax-0.2.3 → optax-0.2.4}/optax/second_order/_fisher.py +5 -5
  83. {optax-0.2.3 → optax-0.2.4}/optax/second_order/_hessian.py +1 -2
  84. {optax-0.2.3 → optax-0.2.4}/optax/second_order/_hessian_test.py +5 -5
  85. {optax-0.2.3 → optax-0.2.4}/optax/transforms/__init__.py +2 -0
  86. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_accumulation.py +110 -81
  87. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_accumulation_test.py +125 -40
  88. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_adding.py +30 -24
  89. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_adding_test.py +30 -14
  90. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_clipping.py +116 -96
  91. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_clipping_test.py +45 -17
  92. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_combining.py +70 -58
  93. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_combining_test.py +35 -27
  94. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_conditionality.py +55 -36
  95. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_conditionality_test.py +48 -41
  96. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_constraining.py +23 -14
  97. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_constraining_test.py +71 -35
  98. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_layouts.py +6 -7
  99. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_layouts_test.py +4 -4
  100. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_masking.py +28 -15
  101. {optax-0.2.3 → optax-0.2.4}/optax/transforms/_masking_test.py +102 -55
  102. {optax-0.2.3 → optax-0.2.4}/optax/tree_utils/__init__.py +5 -0
  103. optax-0.2.4/optax/tree_utils/_casting.py +214 -0
  104. optax-0.2.4/optax/tree_utils/_casting_test.py +107 -0
  105. {optax-0.2.3 → optax-0.2.4}/optax/tree_utils/_random.py +18 -11
  106. optax-0.2.4/optax/tree_utils/_random_test.py +110 -0
  107. {optax-0.2.3 → optax-0.2.4}/optax/tree_utils/_state_utils.py +72 -71
  108. {optax-0.2.3 → optax-0.2.4}/optax/tree_utils/_state_utils_test.py +8 -12
  109. {optax-0.2.3 → optax-0.2.4}/optax/tree_utils/_tree_math.py +63 -39
  110. {optax-0.2.3 → optax-0.2.4}/optax/tree_utils/_tree_math_test.py +96 -37
  111. {optax-0.2.3 → optax-0.2.4}/pyproject.toml +2 -2
  112. optax-0.2.3/optax/_src/factorized_test.py +0 -50
  113. optax-0.2.3/optax/contrib/_common_test.py +0 -147
  114. optax-0.2.3/optax/contrib/_mechanic_test.py +0 -194
  115. optax-0.2.3/optax/contrib/_sam_test.py +0 -203
  116. optax-0.2.3/optax/projections/_projections.py +0 -163
  117. optax-0.2.3/optax/tree_utils/_casting.py +0 -31
  118. optax-0.2.3/optax/tree_utils/_casting_test.py +0 -50
  119. optax-0.2.3/optax/tree_utils/_random_test.py +0 -102
  120. {optax-0.2.3 → optax-0.2.4}/LICENSE +0 -0
  121. {optax-0.2.3 → optax-0.2.4}/optax/_src/clipping.py +0 -0
  122. {optax-0.2.3 → optax-0.2.4}/optax/_src/combine.py +0 -0
  123. {optax-0.2.3 → optax-0.2.4}/optax/_src/constrain.py +0 -0
  124. {optax-0.2.3 → optax-0.2.4}/optax/_src/deprecations.py +0 -0
  125. {optax-0.2.3 → optax-0.2.4}/optax/contrib/__init__.py +0 -0
  126. {optax-0.2.3 → optax-0.2.4}/optax/losses/__init__.py +0 -0
  127. {optax-0.2.3 → optax-0.2.4}/optax/schedules/inject.py +0 -0
  128. {optax-0.2.3 → optax-0.2.4}/optax/second_order/_base.py +0 -0
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: optax
3
- Version: 0.2.3
4
- Summary: A gradient processing and optimisation library in JAX.
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,7 +17,7 @@ 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.86
20
+ Requires-Dist: chex>=0.1.87
21
21
  Requires-Dist: jax>=0.4.27
22
22
  Requires-Dist: jaxlib>=0.4.27
23
23
  Requires-Dist: numpy>=1.18.0
@@ -74,12 +74,12 @@ Our goals are to
74
74
 
75
75
  * Provide simple, well-tested, efficient implementations of core components.
76
76
  * Improve research productivity by enabling to easily combine low-level
77
- ingredients into custom optimisers (or other gradient processing components).
77
+ ingredients into custom optimizers (or other gradient processing components).
78
78
  * Accelerate adoption of new ideas by making it easy for anyone to contribute.
79
79
 
80
- We favour focusing on small composable building blocks that can be effectively
80
+ We favor focusing on small composable building blocks that can be effectively
81
81
  combined into custom solutions. Others may build upon these basic components
82
- in more complicated abstractions. Whenever reasonable, implementations prioritise
82
+ in more complicated abstractions. Whenever reasonable, implementations prioritize
83
83
  readability and structuring code to match standard equations, over code reuse.
84
84
 
85
85
  An initial prototype of this library was made available in JAX's experimental
@@ -154,7 +154,7 @@ git clone https://github.com/google-deepmind/optax.git
154
154
  To run the tests, please execute the following script.
155
155
 
156
156
  ```sh
157
- sh ./test.sh
157
+ sh test.sh
158
158
  ```
159
159
 
160
160
  ### Documentation
@@ -165,7 +165,7 @@ pip install -e ".[docs]"
165
165
  ```
166
166
  Then, execute the following.
167
167
  ```sh
168
- cd docs/
168
+ cd docs
169
169
  make html
170
170
  ```
171
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 optimisers (or other gradient processing components).
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 favour focusing on small composable building blocks that can be effectively
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 prioritise
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
@@ -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 ./test.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
 
@@ -17,9 +17,11 @@
17
17
  # pylint: disable=wrong-import-position
18
18
  # pylint: disable=g-importing-member
19
19
 
20
+ from optax import assignment
20
21
  from optax import contrib
21
22
  from optax import losses
22
23
  from optax import monte_carlo
24
+ from optax import perturbations
23
25
  from optax import projections
24
26
  from optax import schedules
25
27
  from optax import second_order
@@ -33,6 +35,7 @@ from optax._src.alias import adam
33
35
  from optax._src.alias import adamax
34
36
  from optax._src.alias import adamaxw
35
37
  from optax._src.alias import adamw
38
+ from optax._src.alias import adan
36
39
  from optax._src.alias import amsgrad
37
40
  from optax._src.alias import fromage
38
41
  from optax._src.alias import lamb
@@ -44,12 +47,14 @@ from optax._src.alias import nadam
44
47
  from optax._src.alias import nadamw
45
48
  from optax._src.alias import noisy_sgd
46
49
  from optax._src.alias import novograd
50
+ from optax._src.alias import optimistic_adam
47
51
  from optax._src.alias import optimistic_gradient_descent
48
52
  from optax._src.alias import polyak_sgd
49
53
  from optax._src.alias import radam
50
54
  from optax._src.alias import rmsprop
51
55
  from optax._src.alias import rprop
52
56
  from optax._src.alias import sgd
57
+ from optax._src.alias import sign_sgd
53
58
  from optax._src.alias import sm3
54
59
  from optax._src.alias import yogi
55
60
  from optax._src.base import EmptyState
@@ -98,6 +103,7 @@ from optax._src.linesearch import ZoomLinesearchInfo
98
103
  from optax._src.lookahead import lookahead
99
104
  from optax._src.lookahead import LookaheadParams
100
105
  from optax._src.lookahead import LookaheadState
106
+ from optax._src.numerics import safe_increment
101
107
  from optax._src.numerics import safe_int32_increment
102
108
  from optax._src.numerics import safe_norm
103
109
  from optax._src.numerics import safe_root_mean_squares
@@ -115,6 +121,7 @@ from optax._src.transform import scale
115
121
  from optax._src.transform import scale_by_adadelta
116
122
  from optax._src.transform import scale_by_adam
117
123
  from optax._src.transform import scale_by_adamax
124
+ from optax._src.transform import scale_by_adan
118
125
  from optax._src.transform import scale_by_amsgrad
119
126
  from optax._src.transform import scale_by_belief
120
127
  from optax._src.transform import scale_by_distance_over_gradients
@@ -131,12 +138,14 @@ from optax._src.transform import scale_by_rms
131
138
  from optax._src.transform import scale_by_rprop
132
139
  from optax._src.transform import scale_by_rss
133
140
  from optax._src.transform import scale_by_schedule
141
+ from optax._src.transform import scale_by_sign
134
142
  from optax._src.transform import scale_by_sm3
135
143
  from optax._src.transform import scale_by_stddev
136
144
  from optax._src.transform import scale_by_trust_ratio
137
145
  from optax._src.transform import scale_by_yogi
138
146
  from optax._src.transform import ScaleByAdaDeltaState
139
147
  from optax._src.transform import ScaleByAdamState
148
+ from optax._src.transform import ScaleByAdanState
140
149
  from optax._src.transform import ScaleByAmsgradState
141
150
  from optax._src.transform import ScaleByBeliefState
142
151
  from optax._src.transform import ScaleByLBFGSState
@@ -198,6 +207,7 @@ piecewise_constant_schedule = schedules.piecewise_constant_schedule
198
207
  piecewise_interpolate_schedule = schedules.piecewise_interpolate_schedule
199
208
  polynomial_schedule = schedules.polynomial_schedule
200
209
  sgdr_schedule = schedules.sgdr_schedule
210
+ warmup_constant_schedule = schedules.warmup_constant_schedule
201
211
  warmup_cosine_decay_schedule = schedules.warmup_cosine_decay_schedule
202
212
  warmup_exponential_decay_schedule = schedules.warmup_exponential_decay_schedule
203
213
  inject_stateful_hyperparams = schedules.inject_stateful_hyperparams
@@ -280,7 +290,7 @@ del _typing
280
290
  # pylint: enable=g-importing-member
281
291
 
282
292
 
283
- __version__ = "0.2.3"
293
+ __version__ = "0.2.4"
284
294
 
285
295
  __all__ = (
286
296
  "adabelief",
@@ -291,6 +301,7 @@ __all__ = (
291
301
  "adamax",
292
302
  "adamaxw",
293
303
  "adamw",
304
+ "adan",
294
305
  "adaptive_grad_clip",
295
306
  "AdaptiveGradClipState",
296
307
  "add_decayed_weights",
@@ -303,6 +314,7 @@ __all__ = (
303
314
  "apply_updates",
304
315
  "ApplyEvery",
305
316
  "ApplyIfFiniteState",
317
+ "assignment",
306
318
  "centralize",
307
319
  "chain",
308
320
  "clip_by_block_rms",
@@ -385,6 +397,7 @@ __all__ = (
385
397
  "radam",
386
398
  "rmsprop",
387
399
  "rprop",
400
+ "safe_increment",
388
401
  "safe_int32_increment",
389
402
  "safe_norm",
390
403
  "safe_root_mean_squares",
@@ -392,6 +405,7 @@ __all__ = (
392
405
  "scale_by_adadelta",
393
406
  "scale_by_adam",
394
407
  "scale_by_adamax",
408
+ "scale_by_adan",
395
409
  "scale_by_amsgrad",
396
410
  "scale_by_backtracking_linesearch",
397
411
  "scale_by_belief",
@@ -407,6 +421,7 @@ __all__ = (
407
421
  "scale_by_rprop",
408
422
  "scale_by_rss",
409
423
  "scale_by_schedule",
424
+ "scale_by_sign",
410
425
  "scale_by_sm3",
411
426
  "scale_by_stddev",
412
427
  "scale_by_trust_ratio",
@@ -416,6 +431,7 @@ __all__ = (
416
431
  "scale",
417
432
  "ScaleByAdaDeltaState",
418
433
  "ScaleByAdamState",
434
+ "ScaleByAdanState",
419
435
  "ScaleByAmsgradState",
420
436
  "ScaleByBacktrackingLinesearchState",
421
437
  "ScaleByBeliefState",
@@ -437,6 +453,7 @@ __all__ = (
437
453
  "sgdr_schedule",
438
454
  "ShouldSkipUpdateFunction",
439
455
  "sigmoid_binary_cross_entropy",
456
+ "sign_sgd",
440
457
  "skip_large_updates",
441
458
  "skip_not_finite",
442
459
  "sm3",