pytensor-ml 0.2.2__tar.gz → 0.4.0__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 (237) hide show
  1. pytensor_ml-0.4.0/.github/workflows/mypy.yml +34 -0
  2. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.github/workflows/pre-commit.yml +5 -0
  3. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.github/workflows/run_tests.yml +35 -72
  4. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.pre-commit-config.yaml +25 -0
  5. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/PKG-INFO +9 -7
  6. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/README.md +5 -4
  7. pytensor_ml-0.4.0/conda_envs/environment-docs.yml +24 -0
  8. pytensor_ml-0.4.0/conda_envs/pytensor_ml-gpu_jax.yml +22 -0
  9. pytensor_ml-0.4.0/conda_envs/pytensor_ml-gpu_metal.yml +20 -0
  10. pytensor_ml-0.4.0/conda_envs/pytensor_ml.yml +19 -0
  11. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/activations.rst +1 -0
  12. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/layers.rst +6 -0
  13. pytensor_ml-0.4.0/docs/source/api/models.rst +34 -0
  14. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/optim.rst +20 -2
  15. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/state.rst +2 -0
  16. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api.rst +1 -0
  17. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/dev/contributing.rst +13 -3
  18. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/dev/style_guide.rst +1 -1
  19. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/index.rst +9 -2
  20. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/references.bib +43 -0
  21. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/sharp_edges.rst +42 -0
  22. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/examples/gallery/mnist_feed_forward.ipynb +2 -2
  23. pytensor_ml-0.4.0/pixi.lock +14617 -0
  24. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pyproject.toml +104 -8
  25. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/__init__.py +1 -0
  26. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/_version.py +2 -2
  27. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/activations.py +28 -2
  28. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/base.py +69 -1
  29. pytensor_ml-0.4.0/pytensor_ml/checkpoint.py +350 -0
  30. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/jax/__init__.py +1 -0
  31. pytensor_ml-0.4.0/pytensor_ml/dispatch/jax/attention.py +36 -0
  32. pytensor_ml-0.4.0/pytensor_ml/dispatch/jax/line_search.py +42 -0
  33. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/mlx/__init__.py +2 -0
  34. pytensor_ml-0.4.0/pytensor_ml/dispatch/mlx/lbfgs.py +51 -0
  35. pytensor_ml-0.4.0/pytensor_ml/dispatch/mlx/line_search.py +269 -0
  36. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/__init__.py +13 -0
  37. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/attention.py +121 -29
  38. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/conv.py +251 -80
  39. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/dropout.py +3 -3
  40. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/embedding.py +5 -4
  41. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/linear.py +6 -4
  42. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/norm.py +340 -22
  43. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/padding.py +5 -3
  44. pytensor_ml-0.4.0/pytensor_ml/layers/positional.py +368 -0
  45. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/recurrent.py +66 -38
  46. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/transformer.py +44 -15
  47. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/loss.py +39 -11
  48. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/model.py +38 -14
  49. pytensor_ml-0.4.0/pytensor_ml/models/__init__.py +24 -0
  50. pytensor_ml-0.4.0/pytensor_ml/models/architectures/__init__.py +3 -0
  51. pytensor_ml-0.4.0/pytensor_ml/models/architectures/clip.py +190 -0
  52. pytensor_ml-0.4.0/pytensor_ml/models/architectures/gpt2.py +127 -0
  53. pytensor_ml-0.4.0/pytensor_ml/models/architectures/vae.py +343 -0
  54. pytensor_ml-0.4.0/pytensor_ml/models/blocks/__init__.py +4 -0
  55. pytensor_ml-0.4.0/pytensor_ml/models/blocks/attention.py +78 -0
  56. pytensor_ml-0.4.0/pytensor_ml/models/blocks/resnet.py +173 -0
  57. pytensor_ml-0.4.0/pytensor_ml/models/loading/__init__.py +17 -0
  58. pytensor_ml-0.4.0/pytensor_ml/models/loading/binding.py +28 -0
  59. pytensor_ml-0.4.0/pytensor_ml/models/loading/keys.py +224 -0
  60. pytensor_ml-0.4.0/pytensor_ml/models/loading/registry.py +120 -0
  61. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/__init__.py +11 -5
  62. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/alias.py +191 -136
  63. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/base.py +124 -187
  64. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/clipping.py +2 -2
  65. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/guards.py +24 -26
  66. pytensor_ml-0.4.0/pytensor_ml/optim/lbfgs.py +179 -0
  67. pytensor_ml-0.4.0/pytensor_ml/optim/line_search.py +660 -0
  68. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/policy.py +20 -11
  69. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/rules.py +428 -63
  70. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/schedules.py +93 -0
  71. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/train.py +148 -60
  72. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/transform.py +21 -27
  73. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/params.py +30 -6
  74. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/pretrained.py +109 -21
  75. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/pytensorf/__init__.py +2 -0
  76. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/pytensorf/collect.py +86 -19
  77. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/pytensorf/compile.py +20 -31
  78. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/pytensorf/rewrite.py +43 -3
  79. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/pytensorf/rng.py +108 -5
  80. pytensor_ml-0.4.0/pytensor_ml/rewriting/layers.py +216 -0
  81. pytensor_ml-0.4.0/pytensor_ml/rewriting/scan.py +376 -0
  82. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/state.py +73 -9
  83. pytensor_ml-0.4.0/tests/conftest.py +153 -0
  84. pytensor_ml-0.4.0/tests/data/attention_block_2d.npz +0 -0
  85. pytensor_ml-0.4.0/tests/data/generate_reference_checkpoints.py +141 -0
  86. pytensor_ml-0.4.0/tests/data/generate_reference_layers.py +98 -0
  87. pytensor_ml-0.4.0/tests/data/resnet_block_2d.npz +0 -0
  88. pytensor_ml-0.4.0/tests/data/sdxl_vae.npz +0 -0
  89. pytensor_ml-0.4.0/tests/data/tiny_clip/config.json +23 -0
  90. pytensor_ml-0.4.0/tests/data/tiny_clip/expected_outputs.npz +0 -0
  91. pytensor_ml-0.4.0/tests/data/tiny_clip/model.safetensors +0 -0
  92. pytensor_ml-0.4.0/tests/data/tiny_clip_with_projection/config.json +23 -0
  93. pytensor_ml-0.4.0/tests/data/tiny_clip_with_projection/expected_outputs.npz +0 -0
  94. pytensor_ml-0.4.0/tests/data/tiny_clip_with_projection/model.safetensors +0 -0
  95. pytensor_ml-0.4.0/tests/data/tiny_gpt2/config.json +34 -0
  96. pytensor_ml-0.4.0/tests/data/tiny_gpt2/expected_outputs.npz +0 -0
  97. pytensor_ml-0.4.0/tests/data/tiny_gpt2/generation_config.json +9 -0
  98. pytensor_ml-0.4.0/tests/data/tiny_gpt2/model.safetensors +0 -0
  99. pytensor_ml-0.4.0/tests/data/tiny_vae/config.json +31 -0
  100. pytensor_ml-0.4.0/tests/data/tiny_vae/diffusion_pytorch_model.safetensors +0 -0
  101. pytensor_ml-0.4.0/tests/data/tiny_vae/expected_outputs.npz +0 -0
  102. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/jax/test_attention.py +15 -0
  103. pytensor_ml-0.4.0/tests/dispatch/jax/test_line_search.py +99 -0
  104. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/mlx/test_attention.py +20 -1
  105. pytensor_ml-0.4.0/tests/dispatch/mlx/test_lbfgs.py +137 -0
  106. pytensor_ml-0.4.0/tests/dispatch/mlx/test_line_search.py +138 -0
  107. pytensor_ml-0.4.0/tests/dispatch/mlx/test_norm.py +33 -0
  108. pytensor_ml-0.4.0/tests/dispatch/mlx/test_positional.py +33 -0
  109. pytensor_ml-0.4.0/tests/models/architectures/test_clip.py +189 -0
  110. pytensor_ml-0.4.0/tests/models/architectures/test_gpt2.py +121 -0
  111. pytensor_ml-0.4.0/tests/models/architectures/test_vae.py +119 -0
  112. pytensor_ml-0.4.0/tests/models/blocks/__init__.py +0 -0
  113. pytensor_ml-0.4.0/tests/models/blocks/test_attention.py +54 -0
  114. pytensor_ml-0.4.0/tests/models/blocks/test_resnet.py +117 -0
  115. pytensor_ml-0.4.0/tests/models/loading/__init__.py +0 -0
  116. pytensor_ml-0.4.0/tests/models/loading/test_binding.py +11 -0
  117. pytensor_ml-0.4.0/tests/models/loading/test_keys.py +197 -0
  118. pytensor_ml-0.4.0/tests/models/loading/test_registry.py +72 -0
  119. pytensor_ml-0.4.0/tests/optim/__init__.py +0 -0
  120. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/conftest.py +3 -1
  121. pytensor_ml-0.4.0/tests/optim/lbfgs_reference.py +34 -0
  122. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_composition.py +87 -4
  123. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_guards.py +29 -17
  124. pytensor_ml-0.4.0/tests/optim/test_lbfgs.py +185 -0
  125. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_learning_rate.py +3 -16
  126. pytensor_ml-0.4.0/tests/optim/test_line_search.py +241 -0
  127. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_policy.py +15 -3
  128. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_public_surface.py +1 -3
  129. pytensor_ml-0.4.0/tests/optim/test_rules.py +1110 -0
  130. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_schedules.py +47 -0
  131. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_training.py +217 -47
  132. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_transform.py +15 -43
  133. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_update_space.py +3 -53
  134. pytensor_ml-0.4.0/tests/rewriting/__init__.py +0 -0
  135. pytensor_ml-0.4.0/tests/rewriting/test_layers.py +337 -0
  136. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/rewriting/test_scan.py +165 -7
  137. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_activations.py +30 -4
  138. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_attention.py +139 -4
  139. pytensor_ml-0.4.0/tests/test_checkpoint.py +661 -0
  140. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_collect.py +25 -11
  141. pytensor_ml-0.4.0/tests/test_conv.py +570 -0
  142. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_conv_transpose.py +56 -68
  143. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_layers.py +439 -4
  144. pytensor_ml-0.4.0/tests/test_loss.py +134 -0
  145. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_model.py +75 -25
  146. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_padding.py +12 -36
  147. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_pool.py +43 -57
  148. pytensor_ml-0.4.0/tests/test_positional.py +392 -0
  149. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_pretrained.py +254 -20
  150. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_pytensorf.py +116 -4
  151. pytensor_ml-0.4.0/tests/test_recurrent.py +785 -0
  152. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_serialize.py +71 -7
  153. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_state.py +31 -0
  154. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_transformer.py +38 -1
  155. pytensor_ml-0.4.0/tests/test_upsample.py +201 -0
  156. pytensor_ml-0.2.2/.github/workflows/mypy.yml +0 -57
  157. pytensor_ml-0.2.2/conda_envs/environment-docs.yml +0 -35
  158. pytensor_ml-0.2.2/conda_envs/pytensor_ml-gpu_jax.yml +0 -42
  159. pytensor_ml-0.2.2/conda_envs/pytensor_ml.yml +0 -31
  160. pytensor_ml-0.2.2/pixi.lock +0 -10749
  161. pytensor_ml-0.2.2/pytensor_ml/checkpoint.py +0 -171
  162. pytensor_ml-0.2.2/pytensor_ml/dispatch/jax/attention.py +0 -25
  163. pytensor_ml-0.2.2/pytensor_ml/rewriting/layers.py +0 -85
  164. pytensor_ml-0.2.2/pytensor_ml/rewriting/scan.py +0 -188
  165. pytensor_ml-0.2.2/tests/conftest.py +0 -61
  166. pytensor_ml-0.2.2/tests/optim/test_rules.py +0 -560
  167. pytensor_ml-0.2.2/tests/rewriting/conftest.py +0 -23
  168. pytensor_ml-0.2.2/tests/rewriting/test_layers.py +0 -52
  169. pytensor_ml-0.2.2/tests/test_checkpoint.py +0 -223
  170. pytensor_ml-0.2.2/tests/test_conv.py +0 -897
  171. pytensor_ml-0.2.2/tests/test_loss.py +0 -72
  172. pytensor_ml-0.2.2/tests/test_recurrent.py +0 -1279
  173. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.gitattributes +0 -0
  174. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.github/workflows/release.yml +0 -0
  175. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.github/workflows/rtd-preview.yml +0 -0
  176. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.gitignore +0 -0
  177. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/.readthedocs.yaml +0 -0
  178. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/LICENSE +0 -0
  179. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/.gitignore +0 -0
  180. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/Makefile +0 -0
  181. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/make.bat +0 -0
  182. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/_static/.gitkeep +0 -0
  183. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/_templates/autosummary/class.rst +0 -0
  184. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/loss.rst +0 -0
  185. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/model.rst +0 -0
  186. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/pytensorf.rst +0 -0
  187. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/serialization.rst +0 -0
  188. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/api/util.rst +0 -0
  189. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/conf.py +0 -0
  190. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/dev/docs.rst +0 -0
  191. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/dev/index.rst +0 -0
  192. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/source/install.rst +0 -0
  193. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/docs/sphinxext/generate_gallery.py +0 -0
  194. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/__init__.py +0 -0
  195. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/jax/conv.py +0 -0
  196. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/jax/pooling.py +0 -0
  197. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/mlx/attention.py +0 -0
  198. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/mlx/conv.py +0 -0
  199. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/mlx/pooling.py +0 -0
  200. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/numba/__init__.py +0 -0
  201. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/numba/conv.py +0 -0
  202. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/pytorch/__init__.py +0 -0
  203. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/pytorch/conv.py +0 -0
  204. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/dispatch/pytorch/pooling.py +0 -0
  205. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/json_serialize.py +0 -0
  206. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/layers/combinators.py +0 -0
  207. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/optim/checks.py +0 -0
  208. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/rewriting/__init__.py +0 -0
  209. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/rewriting/conv.py +0 -0
  210. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/__init__.py +0 -0
  211. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/base.py +0 -0
  212. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/blockwise.py +0 -0
  213. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/builders.py +0 -0
  214. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/elemwise.py +0 -0
  215. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/scalar.py +0 -0
  216. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/serialize/scan.py +0 -0
  217. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/pytensor_ml/util.py +0 -0
  218. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/scripts/run_mypy.py +0 -0
  219. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/__init__.py +0 -0
  220. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/__init__.py +0 -0
  221. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/jax/__init__.py +0 -0
  222. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/jax/test_basic.py +0 -0
  223. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/jax/test_conv.py +0 -0
  224. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/jax/test_pool.py +0 -0
  225. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/mlx/__init__.py +0 -0
  226. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/mlx/test_basic.py +0 -0
  227. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/mlx/test_conv.py +0 -0
  228. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/mlx/test_pool.py +0 -0
  229. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/pytorch/__init__.py +0 -0
  230. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/pytorch/test_conv.py +0 -0
  231. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/dispatch/pytorch/test_pool.py +0 -0
  232. {pytensor_ml-0.2.2/tests/optim → pytensor_ml-0.4.0/tests/models}/__init__.py +0 -0
  233. {pytensor_ml-0.2.2/tests/rewriting → pytensor_ml-0.4.0/tests/models/architectures}/__init__.py +0 -0
  234. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/optim/test_clipping.py +0 -0
  235. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_base.py +0 -0
  236. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_util.py +0 -0
  237. {pytensor_ml-0.2.2 → pytensor_ml-0.4.0}/tests/test_workflow_groups.py +0 -0
@@ -0,0 +1,34 @@
1
+ name: mypy
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ paths:
8
+ - ".github/workflows/mypy.yml"
9
+ - "pytensor_ml/**"
10
+ - "scripts/run_mypy.py"
11
+ - "pyproject.toml"
12
+ - "pixi.lock"
13
+
14
+ # Cancels all previous workflow runs for pull requests that have not completed.
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ mypy:
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25
+ - uses: prefix-dev/setup-pixi@9dabb60412d3d2d967a8d682f7ce01317af40514 # v0.11.0
26
+ with:
27
+ pixi-version: v0.81.0
28
+ environments: mypy
29
+ activate-environment: true
30
+ locked: true
31
+ cache: true
32
+
33
+ - name: Run mypy
34
+ run: python ./scripts/run_mypy.py
@@ -13,4 +13,9 @@ jobs:
13
13
  steps:
14
14
  - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
15
15
  - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
16
+ # The pixi hooks call pixi directly and need no environment installed.
17
+ - uses: prefix-dev/setup-pixi@9dabb60412d3d2d967a8d682f7ce01317af40514 # v0.11.0
18
+ with:
19
+ pixi-version: v0.81.0
20
+ run-install: false
16
21
  - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
@@ -14,17 +14,14 @@ concurrency:
14
14
 
15
15
  jobs:
16
16
  unittest:
17
- name: unittest (${{ matrix.os }}, ${{ matrix.python-version }}, ${{ matrix.test-subset.name }})
17
+ name: unittest (${{ matrix.os }}, ${{ matrix.test-subset.name }})
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
21
  os: [ubuntu-latest]
22
- python-version: ["3.12"]
23
- # Off by default, flipped to 1 by the per-backend jobs under `include`. A core job installs no
24
- # backend at all, which is what proves the library runs without one.
25
- install-jax: [0]
26
- install-mlx: [0]
27
- install-torch: [0]
22
+ # The per-backend jobs under `include` swap in an environment carrying their one backend. A core
23
+ # job's environment has no backend at all, which is what proves the library runs without one.
24
+ pixi-environment: [test]
28
25
  # Groups are balanced on measured cold-compile-cache time, which is what a fresh runner pays.
29
26
  # tests/test_workflow_groups.py fails if a test file is missing from every group or listed twice.
30
27
  test-subset:
@@ -35,15 +32,25 @@ jobs:
35
32
  paths: |
36
33
  tests/test_transformer.py
37
34
  tests/test_layers.py
35
+ tests/test_positional.py
36
+ - name: recurrent
37
+ paths: |
38
38
  tests/test_recurrent.py
39
+ tests/rewriting/
40
+ - name: convolution
41
+ paths: |
39
42
  tests/test_conv.py
40
43
  tests/test_conv_transpose.py
41
44
  tests/test_padding.py
42
45
  tests/test_pool.py
43
- tests/rewriting/
46
+ tests/test_upsample.py
44
47
  - name: optim
45
48
  paths: |
46
49
  tests/optim/
50
+ - name: models
51
+ paths: |
52
+ tests/test_pretrained.py
53
+ tests/models/
47
54
  - name: rest
48
55
  paths: |
49
56
  tests/test_serialize.py
@@ -51,7 +58,6 @@ jobs:
51
58
  tests/test_loss.py
52
59
  tests/test_checkpoint.py
53
60
  tests/test_model.py
54
- tests/test_pretrained.py
55
61
  tests/test_pytensorf.py
56
62
  tests/test_state.py
57
63
  tests/test_base.py
@@ -64,25 +70,22 @@ jobs:
64
70
  # `test-subset` because a matrix entry cannot change `os`, and mlx needs macOS.
65
71
  include:
66
72
  - os: ubuntu-latest
67
- python-version: "3.12"
68
- install-jax: 1
73
+ pixi-environment: test-jax
69
74
  test-subset:
70
75
  name: dispatch-jax
71
76
  paths: tests/dispatch/jax/
72
77
  - os: macos-15
73
- python-version: "3.12"
74
- install-mlx: 1
78
+ pixi-environment: test-mlx
75
79
  test-subset:
76
80
  name: dispatch-mlx
77
81
  paths: tests/dispatch/mlx/
78
82
  - os: ubuntu-latest
79
- python-version: "3.12"
80
- install-torch: 1
83
+ pixi-environment: test-torch
81
84
  test-subset:
82
85
  name: dispatch-torch
83
86
  paths: tests/dispatch/pytorch/
84
87
  - os: windows-latest
85
- python-version: "3.12"
88
+ pixi-environment: test
86
89
  test-subset:
87
90
  name: smoke
88
91
  paths: |
@@ -95,73 +98,33 @@ jobs:
95
98
  env:
96
99
  TEST_SUBSET: ${{ matrix.test-subset.paths }}
97
100
 
98
- defaults:
99
- run:
100
- shell: bash -l {0}
101
-
102
101
  steps:
103
102
  - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
104
- - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
105
- env:
106
- CACHE_NUMBER: 0
103
+ - uses: prefix-dev/setup-pixi@9dabb60412d3d2d967a8d682f7ce01317af40514 # v0.11.0
107
104
  with:
108
- path: ~/conda_pkgs_dir
109
- key: ${{ runner.os }}-py${{matrix.python-version}}-conda-${{ env.CACHE_NUMBER }}-${{
110
- hashFiles('conda_envs/pytensor_ml.yml') }}
111
- - name: Cache multiple paths
112
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
113
- env:
114
- # Increase this value to reset cache if pyproject.toml has not changed
115
- CACHE_NUMBER: 0
116
- with:
117
- path: |
118
- ~/.cache/pip
119
- $RUNNER_TOOL_CACHE/Python/*
120
- ~\AppData\Local\pip\Cache
121
- key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{
122
- hashFiles('pyproject.toml') }}
105
+ pixi-version: v0.81.0
106
+ environments: ${{ matrix.pixi-environment }}
107
+ activate-environment: true
108
+ locked: true
109
+ cache: true
110
+ # A saved cache entry is immutable, so a key without the commit would freeze the cache at the first
111
+ # run on each lockfile, and every graph changed after it would compile cold on every run. Keying on
112
+ # the commit saves a fresh entry each run, and the restore keys pick up the newest one.
123
113
  - name: Cache the pytensor compile directory
124
114
  uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
125
115
  env:
126
116
  CACHE_NUMBER: 0
127
117
  with:
128
- path: ~/.pytensor
129
- key: ${{ runner.os }}-py${{ matrix.python-version }}-pytensor-${{ env.CACHE_NUMBER }}-${{
130
- matrix.test-subset.name }}-${{ hashFiles('conda_envs/pytensor_ml.yml') }}
118
+ # pytensor compiles into %LOCALAPPDATA%\PyTensor on Windows and ~/.pytensor elsewhere.
119
+ path: ${{ runner.os == 'Windows' && '~/AppData/Local/PyTensor' || '~/.pytensor' }}
120
+ key: ${{ runner.os }}-pytensor-${{ env.CACHE_NUMBER }}-${{
121
+ matrix.test-subset.name }}-${{ hashFiles('pixi.lock') }}-${{ github.sha }}
131
122
  restore-keys: |
132
- ${{ runner.os }}-py${{ matrix.python-version }}-pytensor-${{ env.CACHE_NUMBER }}-${{ matrix.test-subset.name }}-
133
- - uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
134
- with:
135
- miniforge-variant: Miniforge3
136
- miniforge-version: latest
137
- mamba-version: "*"
138
- activate-environment: pytensor_ml
139
- channel-priority: strict
140
- environment-file: conda_envs/pytensor_ml.yml
141
- python-version: 3.12
142
- use-mamba: true
143
-
144
- # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267
145
- use-only-tar-bz2: false
146
-
147
- - name: Install the backend this job tests
148
- run: |
149
- conda activate pytensor_ml
150
- if [[ $INSTALL_JAX == "1" ]]; then pip install "jax>=0.8,<0.9.1" jaxlib; fi
151
- if [[ $INSTALL_MLX == "1" ]]; then pip install "mlx>=0.30,<0.32"; fi
152
- if [[ $INSTALL_TORCH == "1" ]]; then pip install torch --index-url https://download.pytorch.org/whl/cpu; fi
153
- env:
154
- INSTALL_JAX: ${{ matrix.install-jax }}
155
- INSTALL_MLX: ${{ matrix.install-mlx }}
156
- INSTALL_TORCH: ${{ matrix.install-torch }}
157
-
158
- - name: Install current branch
159
- run: |
160
- conda activate pytensor_ml
161
- pip install -e .
162
- python --version
123
+ ${{ runner.os }}-pytensor-${{ env.CACHE_NUMBER }}-${{ matrix.test-subset.name }}-${{ hashFiles('pixi.lock') }}-
124
+ ${{ runner.os }}-pytensor-${{ env.CACHE_NUMBER }}-${{ matrix.test-subset.name }}-
163
125
 
164
126
  - name: Run tests
127
+ shell: bash
165
128
  run: |
166
129
  python -m pytest -vv --durations=25 --cov=pytensor_ml --cov-report=xml --no-cov-on-fail --cov-report term $TEST_SUBSET
167
130
  - name: Upload coverage to Codecov
@@ -32,6 +32,31 @@ repos:
32
32
 
33
33
  - repo: local
34
34
  hooks:
35
+ - id: pixi-lock-check
36
+ name: pixi.lock is in sync with pyproject.toml
37
+ entry: pixi lock --check
38
+ language: system
39
+ files: ^(pyproject\.toml|pixi\.lock)$
40
+ pass_filenames: false
41
+
42
+ - id: pixi-export-dev
43
+ name: conda_envs/pytensor_ml.yml is exported from the pixi dev environment
44
+ # Called directly rather than through a pixi task so the hook reads the manifest only; `pixi run`
45
+ # would re-solve the lock file and install the environment first. --no-pypi drops the editable
46
+ # install, because conda runs pip from the env file's directory, where `-e .` names conda_envs/.
47
+ # -p pins the export to one platform, so it does not depend on the machine running the hook.
48
+ entry: pixi workspace export conda-environment -e dev -n pytensor_ml -p linux-64 --no-pypi conda_envs/pytensor_ml.yml
49
+ language: system
50
+ files: ^(pyproject\.toml|pixi\.lock|conda_envs/pytensor_ml\.yml)$
51
+ pass_filenames: false
52
+
53
+ - id: pixi-export-docs
54
+ name: conda_envs/environment-docs.yml is exported from the pixi docs environment
55
+ entry: pixi workspace export conda-environment -e docs -n pytensor_ml-docs -p linux-64 --no-pypi conda_envs/environment-docs.yml
56
+ language: system
57
+ files: ^(pyproject\.toml|pixi\.lock|conda_envs/environment-docs\.yml)$
58
+ pass_filenames: false
59
+
35
60
  - id: notebook_name
36
61
  entry: '\(notebook_name\)='
37
62
  language: pygrep
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pytensor_ml
3
- Version: 0.2.2
3
+ Version: 0.4.0
4
4
  Summary: A(nother) deep learning library, built on top of Pytensor
5
5
  Project-URL: Homepage, https://github.com/pymc-devs/pytensor-ml
6
6
  Project-URL: Documentation, https://pytensor-ml.readthedocs.io
@@ -25,15 +25,16 @@ Classifier: Programming Language :: Python :: 3.14
25
25
  Classifier: Topic :: Scientific/Engineering
26
26
  Requires-Python: >=3.12
27
27
  Requires-Dist: numpy
28
- Requires-Dist: pytensor<4.0.0,>=3.2.3
29
- Requires-Dist: safetensors
28
+ Requires-Dist: pytensor<4.0.0,>=3.3.8
30
29
  Provides-Extra: dev
30
+ Requires-Dist: cloudpickle; extra == 'dev'
31
31
  Requires-Dist: jax; extra == 'dev'
32
32
  Requires-Dist: mypy; extra == 'dev'
33
33
  Requires-Dist: pre-commit; extra == 'dev'
34
34
  Requires-Dist: pytest; extra == 'dev'
35
35
  Requires-Dist: pytest-cov; extra == 'dev'
36
36
  Requires-Dist: pyyaml; extra == 'dev'
37
+ Requires-Dist: safetensors; extra == 'dev'
37
38
  Requires-Dist: scikit-learn; extra == 'dev'
38
39
  Provides-Extra: examples
39
40
  Requires-Dist: matplotlib; extra == 'examples'
@@ -61,8 +62,9 @@ any other PyTensor graph — a PyMC model included — as there is nothing else
61
62
  pip install pytensor-ml
62
63
  ```
63
64
 
64
- The only hard dependencies are `pytensor`, `numpy`, and `safetensors`. A backend beyond the default (`numba`,
65
- `jax`, `torch`, `mlx`) is installed separately, and only loads when you actually compile against it.
65
+ The only hard dependencies are `pytensor` and `numpy`. Saving and loading weights needs `safetensors`
66
+ (`pip install safetensors`). A backend beyond the default (`numba`, `jax`, `torch`, `mlx`) is installed
67
+ separately, and only loads when you actually compile against it.
66
68
 
67
69
  ## Quickstart
68
70
 
@@ -93,11 +95,11 @@ network = Sequential(
93
95
  ReLU(),
94
96
  Linear("logits", n_in=128, n_out=10),
95
97
  )
96
- model = Model(X_in, network(X_in)).initialize(seed=0)
98
+ model = Model(network(X_in)).initialize(seed=0)
97
99
 
98
100
  rule = chain(clip_by_global_norm(1.0), adam(learning_rate=cosine_schedule(1e-3, total_steps=500)))
99
101
  loss_fn = CrossEntropy(expect_onehot_labels=True, expect_logits=True, reduction="mean")
100
- step = model.compile_train(rule, loss_fn, ndim_out=2)
102
+ step = model.compile_train(rule, loss_fn)
101
103
 
102
104
  loader = DataLoader(X, y_onehot, batch_size=64, random_state=0)
103
105
  for _ in range(500):
@@ -19,8 +19,9 @@ any other PyTensor graph — a PyMC model included — as there is nothing else
19
19
  pip install pytensor-ml
20
20
  ```
21
21
 
22
- The only hard dependencies are `pytensor`, `numpy`, and `safetensors`. A backend beyond the default (`numba`,
23
- `jax`, `torch`, `mlx`) is installed separately, and only loads when you actually compile against it.
22
+ The only hard dependencies are `pytensor` and `numpy`. Saving and loading weights needs `safetensors`
23
+ (`pip install safetensors`). A backend beyond the default (`numba`, `jax`, `torch`, `mlx`) is installed
24
+ separately, and only loads when you actually compile against it.
24
25
 
25
26
  ## Quickstart
26
27
 
@@ -51,11 +52,11 @@ network = Sequential(
51
52
  ReLU(),
52
53
  Linear("logits", n_in=128, n_out=10),
53
54
  )
54
- model = Model(X_in, network(X_in)).initialize(seed=0)
55
+ model = Model(network(X_in)).initialize(seed=0)
55
56
 
56
57
  rule = chain(clip_by_global_norm(1.0), adam(learning_rate=cosine_schedule(1e-3, total_steps=500)))
57
58
  loss_fn = CrossEntropy(expect_onehot_labels=True, expect_logits=True, reduction="mean")
58
- step = model.compile_train(rule, loss_fn, ndim_out=2)
59
+ step = model.compile_train(rule, loss_fn)
59
60
 
60
61
  loader = DataLoader(X, y_onehot, batch_size=64, random_state=0)
61
62
  for _ in range(500):
@@ -0,0 +1,24 @@
1
+ name: pytensor_ml-docs
2
+ channels:
3
+ - conda-forge
4
+ - nodefaults
5
+ dependencies:
6
+ - safetensors *
7
+ - matplotlib *
8
+ - ipython *
9
+ - jupyter *
10
+ - sphinx >=7
11
+ - pydata-sphinx-theme *
12
+ - myst-nb *
13
+ - numpydoc *
14
+ - sphinx-copybutton *
15
+ - sphinx-design *
16
+ - sphinx-codeautolink *
17
+ - sphinx-sitemap *
18
+ - sphinx-notfound-page *
19
+ - sphinx-autobuild *
20
+ - jupyter-sphinx *
21
+ - sphinxcontrib-bibtex *
22
+ - pytensor >=3.3.8,<3.4.0
23
+ - numpy *
24
+ - python >=3.12
@@ -0,0 +1,22 @@
1
+ name: pytensor_ml-gpu_jax
2
+ channels:
3
+ - conda-forge
4
+ - nodefaults
5
+ dependencies:
6
+ - safetensors *
7
+ - scikit-learn *
8
+ - cloudpickle *
9
+ - pytest *
10
+ - pytest-cov *
11
+ - pytest-xdist *
12
+ - pytest-benchmark *
13
+ - pytest-mock *
14
+ - pyyaml *
15
+ - mypy >=2.4.0,<2.5.0
16
+ - pre-commit *
17
+ - jax >=0.12,<0.13
18
+ - jaxlib >=0.12,<0.13 cuda*
19
+ - cuda-nvcc *
20
+ - pytensor >=3.3.8,<3.4.0
21
+ - numpy *
22
+ - python >=3.12
@@ -0,0 +1,20 @@
1
+ name: pytensor_ml-gpu_metal
2
+ channels:
3
+ - conda-forge
4
+ - nodefaults
5
+ dependencies:
6
+ - safetensors *
7
+ - scikit-learn *
8
+ - cloudpickle *
9
+ - pytest *
10
+ - pytest-cov *
11
+ - pytest-xdist *
12
+ - pytest-benchmark *
13
+ - pytest-mock *
14
+ - pyyaml *
15
+ - mypy >=2.4.0,<2.5.0
16
+ - pre-commit *
17
+ - mlx >=0.32.4,<0.33
18
+ - pytensor >=3.3.8,<3.4.0
19
+ - numpy *
20
+ - python >=3.12
@@ -0,0 +1,19 @@
1
+ name: pytensor_ml
2
+ channels:
3
+ - conda-forge
4
+ - nodefaults
5
+ dependencies:
6
+ - safetensors *
7
+ - scikit-learn *
8
+ - cloudpickle *
9
+ - pytest *
10
+ - pytest-cov *
11
+ - pytest-xdist *
12
+ - pytest-benchmark *
13
+ - pytest-mock *
14
+ - pyyaml *
15
+ - mypy >=2.4.0,<2.5.0
16
+ - pre-commit *
17
+ - pytensor >=3.3.8,<3.4.0
18
+ - numpy *
19
+ - python >=3.12
@@ -10,6 +10,7 @@ Activations
10
10
  ReLU
11
11
  LeakyReLU
12
12
  GELU
13
+ QuickGELU
13
14
  Swish
14
15
  Sigmoid
15
16
  SoftPlus
@@ -46,6 +46,8 @@ Convolution and pooling
46
46
  MaxPool2D
47
47
  AvgPool1D
48
48
  AvgPool2D
49
+ Upsample1D
50
+ Upsample2D
49
51
 
50
52
  Padding
51
53
  -------
@@ -70,6 +72,8 @@ Normalization and regularization
70
72
 
71
73
  BatchNorm
72
74
  LayerNorm
75
+ RMSNorm
76
+ GroupNorm
73
77
  Dropout
74
78
 
75
79
  Recurrent
@@ -99,3 +103,5 @@ Attention and transformers
99
103
  FeedForward
100
104
  TransformerBlock
101
105
  scaled_dot_product_attention
106
+ RotaryEmbedding
107
+ rotary_embedding
@@ -0,0 +1,34 @@
1
+ Pretrained models
2
+ =================
3
+
4
+ .. currentmodule:: pytensor_ml.models
5
+
6
+ Dispatch
7
+ --------
8
+
9
+ .. autosummary::
10
+ :toctree: generated/
11
+
12
+ architecture_name
13
+ build_from_config
14
+ register_builder
15
+
16
+ Blocks
17
+ ------
18
+
19
+ .. autosummary::
20
+ :toctree: generated/
21
+
22
+ ResnetBlock2D
23
+ AttentionBlock2D
24
+
25
+ Binding weights
26
+ ---------------
27
+
28
+ .. autosummary::
29
+ :toctree: generated/
30
+
31
+ KeyMap
32
+ bind_layer_norm
33
+ bind_linear
34
+ channels_last
@@ -10,6 +10,7 @@ Training
10
10
  :toctree: generated/
11
11
 
12
12
  compile_train
13
+ build_train_updates
13
14
 
14
15
  Update rules
15
16
  ------------
@@ -26,6 +27,16 @@ Update rules
26
27
  rprop
27
28
  adagrad
28
29
  adadelta
30
+ lbfgs
31
+
32
+ Line searches
33
+ -------------
34
+
35
+ .. autosummary::
36
+ :toctree: generated/
37
+
38
+ zoom_line_search
39
+ LineSearch
29
40
 
30
41
  Transforms
31
42
  ----------
@@ -73,6 +84,7 @@ eliminated the value's last consumer.
73
84
 
74
85
  constant_schedule
75
86
  linear_schedule
87
+ linear_onecycle_schedule
76
88
  cosine_schedule
77
89
  exponential_schedule
78
90
  polynomial_schedule
@@ -85,9 +97,7 @@ Building blocks
85
97
  .. autosummary::
86
98
  :toctree: generated/
87
99
 
88
- counter
89
100
  get_gradients
90
- reuses_state
91
101
  scalar_state
92
102
  state_for
93
103
  steps_of
@@ -131,3 +141,11 @@ Low-level update functions
131
141
  rprop_updates
132
142
  adagrad_updates
133
143
  adadelta_updates
144
+ lbfgs_updates
145
+
146
+ .. currentmodule:: pytensor_ml.optim.lbfgs
147
+
148
+ .. autosummary::
149
+ :toctree: generated/
150
+
151
+ LBFGSDirection
@@ -33,5 +33,7 @@ Initializers
33
33
  XavierUniformInitializer
34
34
  OrthogonalInitializer
35
35
  UnrecordedInitializer
36
+ EmptyInitializer
37
+ initial_values_from
36
38
  initialize_params
37
39
  fans
@@ -14,5 +14,6 @@ API Reference
14
14
  api/optim
15
15
  api/state
16
16
  api/serialization
17
+ api/models
17
18
  api/pytensorf
18
19
  api/util
@@ -18,13 +18,23 @@ Setting up
18
18
  pip install -e ".[dev]"
19
19
  pre-commit install
20
20
 
21
- The conda environments under ``conda_envs/`` are what CI installs, pinned
22
- harder than the package metadata. Reach for one when a failure reproduces in CI
23
- but not locally:
21
+ CI installs the pixi environments locked in ``pixi.lock``, pinned harder than
22
+ the package metadata. Reach for one when a failure reproduces in CI but not
23
+ locally:
24
+
25
+ .. code-block:: bash
26
+
27
+ pixi run -e test pytest # the core jobs; test-jax, test-mlx, test-torch for a backend
28
+ pixi run -e mypy python scripts/run_mypy.py
29
+
30
+ ``conda_envs/pytensor_ml.yml`` is exported from the pixi ``dev`` environment by a
31
+ pre-commit hook, for setting up with conda instead:
24
32
 
25
33
  .. code-block:: bash
26
34
 
27
35
  conda env create -f conda_envs/pytensor_ml.yml
36
+ conda activate pytensor_ml
37
+ pip install -e .
28
38
 
29
39
  Docs are built with pixi, which owns its own environment:
30
40
 
@@ -180,7 +180,7 @@ Every public entrypoint carries an ``Examples`` section. Three rules:
180
180
  from pytensor_ml.optim import adam, chain, clip_by_global_norm, compile_train
181
181
 
182
182
  X = Input("X", shape=(None, 4))
183
- loss, target = supervised_loss(Linear("fc", n_in=4, n_out=1)(X), SquaredError(), ndim_out=2)
183
+ loss, target = supervised_loss(Linear("fc", n_in=4, n_out=1)(X), SquaredError())
184
184
 
185
185
  step = compile_train(loss, chain(clip_by_global_norm(1.0), adam(1e-3)))
186
186
  loss_value = step(np.zeros((8, 4)), np.zeros((8, 1)))
@@ -41,6 +41,9 @@ Quick example
41
41
 
42
42
  import numpy as np
43
43
 
44
+ from pytensor import config
45
+ from sklearn.datasets import load_digits
46
+
44
47
  from pytensor_ml.activations import ReLU
45
48
  from pytensor_ml.layers import Input, Linear, Sequential
46
49
  from pytensor_ml.loss import CrossEntropy
@@ -48,17 +51,21 @@ Quick example
48
51
  from pytensor_ml.optim import adam, chain, clip_by_global_norm, cosine_schedule
49
52
  from pytensor_ml.util import DataLoader
50
53
 
54
+ X, y = load_digits(return_X_y=True)
55
+ X = (X / 16.0).astype(config.floatX)
56
+ y_onehot = np.eye(10, dtype=config.floatX)[y]
57
+
51
58
  X_in = Input("X_in", shape=(None, 64))
52
59
  network = Sequential(
53
60
  Linear("fc1", n_in=64, n_out=128),
54
61
  ReLU(),
55
62
  Linear("logits", n_in=128, n_out=10),
56
63
  )
57
- model = Model(X_in, network(X_in)).initialize(seed=0)
64
+ model = Model(network(X_in)).initialize(seed=0)
58
65
 
59
66
  rule = chain(clip_by_global_norm(1.0), adam(learning_rate=cosine_schedule(1e-3, total_steps=500)))
60
67
  loss_fn = CrossEntropy(expect_onehot_labels=True, expect_logits=True, reduction="mean")
61
- step = model.compile_train(rule, loss_fn, ndim_out=2)
68
+ step = model.compile_train(rule, loss_fn)
62
69
 
63
70
  loader = DataLoader(X, y_onehot, batch_size=64, random_state=0)
64
71
  for _ in range(500):