Skip to content

Commit eae59d0

Browse files
authoredOct 17, 2019
Moved all notebooks to docs/notebooks. (jax-ml#1493)
* Moved all notebooks to docs/notebooks. Now all notebooks are in the same place, thus all are subject to auto-doc generation at readthedocs.io and to automated testing with travis. Some notebooks are too slow, exclude them at docs/conf.py:exclude_patterns. Cleanup a bit the section headings in notebooks so that they show up well in readtehdocs.io. * Increase the cell timeout for executing notebooks * Exclude also the neural network notebook from auto-generation (timing out) * Disable the score_matching notebook from auto-doc (travis does not have sklearn)
1 parent 0db8b58 commit eae59d0

14 files changed

+1653
-1582
lines changed
 

‎README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,17 @@ open](https://github.com/google/jax) by a growing number of
8585
## Quickstart: Colab in the Cloud
8686
Jump right in using a notebook in your browser, connected to a Google Cloud GPU. Here are some starter notebooks:
8787
- [The basics: NumPy on accelerators, `grad` for differentiation, `jit` for compilation, and `vmap` for vectorization](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/quickstart.ipynb)
88-
- [Training a Simple Neural Network, with PyTorch Data Loading](https://colab.research.google.com/github/google/jax/blob/master/notebooks/neural_network_and_data_loading.ipynb)
89-
- [Training a Simple Neural Network, with TensorFlow Dataset Data Loading](https://colab.research.google.com/github/google/jax/blob/master/notebooks/neural_network_with_tfds_data.ipynb)
88+
- [Training a Simple Neural Network, with PyTorch Data Loading](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/Neural_Network_and_Data_Loading.ipynb)
89+
- [Training a Simple Neural Network, with TensorFlow Dataset Data Loading](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/neural_network_with_tfds_data.ipynb)
9090

9191
And for a deeper dive into JAX:
9292
- [Common gotchas and sharp edges](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/Common_Gotchas_in_JAX.ipynb)
9393
- [The Autodiff Cookbook, Part 1: easy and powerful automatic differentiation in JAX](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/autodiff_cookbook.ipynb)
94-
- [Directly using XLA in Python](https://colab.research.google.com/github/google/jax/blob/master/notebooks/XLA_in_Python.ipynb)
95-
- [MAML Tutorial with JAX](https://colab.research.google.com/github/google/jax/blob/master/notebooks/maml.ipynb)
96-
- [Generative Modeling by Estimating Gradients of Data Distribution in JAX](https://colab.research.google.com/github/google/jax/blob/master/notebooks/score_matching.ipynb).
97-
[How JAX primitives work](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/How_JAX_primitives_work.ipynb)
94+
- [Directly using XLA in Python](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/XLA_in_Python.ipynb)
95+
- [How JAX primitives work](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/How_JAX_primitives_work.ipynb)
96+
- [MAML Tutorial with JAX](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/maml.ipynb)
97+
- [Generative Modeling by Estimating Gradients of Data Distribution in JAX](https://colab.research.google.com/github/google/jax/blob/master/docs/notebooks/score_matching.ipynb).
98+
9899

99100
## Installation
100101
JAX is written in pure Python, but it depends on XLA, which needs to be compiled

‎docs/conf.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@
8989
# List of patterns, relative to source directory, that match files and
9090
# directories to ignore when looking for source files.
9191
# This pattern also affects html_static_path and html_extra_path.
92-
exclude_patterns = []
92+
exclude_patterns = [
93+
# Slow notebook: long time to load tf.ds
94+
'notebooks/neural_network_with_tfds_data.ipynb',
95+
'notebooks/Neural_Network_and_Data_Loading.ipynb',
96+
# Next one needs sklearn, which is not available at Travis.
97+
'notebooks/score_matching.ipynb'
98+
]
9399

94100
# The name of the Pygments (syntax highlighting) style to use.
95101
pygments_style = None
@@ -101,6 +107,7 @@
101107
# -- Options for nbsphinx -----------------------------------------------------
102108

103109
# Execute notebooks before conversion: 'always', 'never', 'auto' (default)
110+
# We execute all notebooks, exclude the slow ones using 'exclude_patterns'
104111
nbsphinx_execute = 'always'
105112

106113
# Use this kernel instead of the one stored in the notebook metadata:
@@ -114,7 +121,7 @@
114121

115122

116123
# Controls when a cell will time out (defaults to 30; use -1 for no timeout):
117-
nbsphinx_timeout = 60
124+
nbsphinx_timeout = 90
118125

119126
# Default Pygments lexer for syntax highlighting in code cells:
120127
#nbsphinx_codecell_lexer = 'ipython3'

‎docs/developer.rst

+22-5
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,35 @@ The Colab notebooks are tested for errors as part of the documentation build.
9494
Update documentation
9595
====================
9696

97-
To rebuild the documentation,
98-
install the ``sphinx`` and ``sphinx_rtd_theme`` pip
99-
packages and then run at the top-level:
97+
To rebuild the documentation, install several packages:
10098

10199
.. code-block:: shell
102100
103-
sphinx-build -M html docs docs/build
101+
pip install -r docs/requirements.txt
104102
103+
You must also install ``pandoc`` in order to regenerate the notebooks.
104+
See `Install Pandoc <https://pandoc.org/installing.html>`_. On Mac, I had success with
105+
the miniconda installer, then ``conda install -c conda-forge pandoc``.
106+
If you do not want to install ``pandoc`` then you should regenerate the documentation
107+
without the notebooks.
108+
109+
You run at top-level one of the following commands:
110+
111+
.. code-block:: shell
112+
113+
sphinx-build -b html docs docs/build/html # with the notebooks
114+
sphinx-build -b html -D nbsphinx_execute=never docs docs/build/html # without the notebooks
105115
106116
You can then see the generated documentation in
107117
``docs/build/html/index.html``.
108118

119+
Update notebooks
120+
----------------
121+
122+
Open the notebook with http://colab.research.google.com, update it, ``Run all cells`` then
123+
``Download ipynb``. You may want to test that it executes properly, using ``sphinx-build`` as
124+
explained above.
125+
109126
Documentation building on readthedocs.io
110127
----------------------------------------
111128

@@ -115,7 +132,7 @@ The documentation building is controlled for the entire project by the
115132
`readthedocs JAX settings <https://readthedocs.org/dashboard/jax>`_. The current settings
116133
trigger a documentation build as soon as code is pushed to the GitHub ``master`` branch.
117134
For each code version, the building process is driven by the
118-
:file:`.readthedocs.yml` and the ``docs/conf.py`` configuration files.
135+
``.readthedocs.yml`` and the ``docs/conf.py`` configuration files.
119136

120137
For each automated documentation build you can see the
121138
`documentation build logs <https://readthedocs.org/projects/jax/builds/>`_.

‎docs/index.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@ For an introduction to JAX, start at the
1313

1414
notebooks/quickstart
1515
notebooks/autodiff_cookbook
16+
Training a Simple Neural Network, with PyTorch Data Loading <https://github.com/google/jax/blob/master/docs/notebooks/Neural_Network_and_Data_Loading.ipynb>
17+
1618

1719
.. toctree::
1820
:maxdepth: 1
19-
:caption: Advanced Tutorials
21+
:caption: Advanced JAX Tutorials
2022

2123
notebooks/Common_Gotchas_in_JAX
24+
notebooks/XLA_in_Python
2225
notebooks/How_JAX_primitives_work
26+
Training a Simple Neural Network, with Tensorflow Datasets Data Loading <https://github.com/google/jax/blob/master/docs/notebooks/neural_network_with_tfds_data.ipynb>
27+
notebooks/maml
28+
Generative Modeling by Estimating Gradients of Data Distribution <https://github.com/google/jax/blob/master/docs/notebooks/score_matching.ipynb>
29+
notebooks/vmapped_log_probs
2330

2431
.. toctree::
2532
:maxdepth: 1

0 commit comments

Comments
 (0)