Skip to content

Commit

Permalink
Improve documentation:
Browse files Browse the repository at this point in the history
(1) add more structure, e.g. list clickable layers with detailed signature on separate pages, instead of a monolithic wall of text.
(2) Add drop-down TOC on the left, and some simple sections like linear / nonlinear layers etc.
(3) Type rendering is improved following prior change introducting typing protocols.
(4) All sphinx warnings are fixed, so we can now `fail_on_warning`, which will prevent silent errors / empty docs happening in the past.

PiperOrigin-RevId: 429647336
  • Loading branch information
romanngg committed Feb 18, 2022
1 parent b0d489e commit 22b3aae
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 39 deletions.
1 change: 1 addition & 0 deletions .readthedocs.yml
Expand Up @@ -8,6 +8,7 @@ version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
fail_on_warning: True

# Optionally build your docs in additional formats such as PDF and ePub
formats:
Expand Down
8 changes: 8 additions & 0 deletions docs/batching.rst
@@ -0,0 +1,8 @@
Batching -- using multiple devices
============================================================

.. default-role:: code
.. automodule:: neural_tangents._src.batching
.. automodule:: neural_tangents
:noindex:
:members: batch
15 changes: 14 additions & 1 deletion docs/conf.py
Expand Up @@ -46,6 +46,8 @@
'sphinx_autodoc_typehints',
]

# set_type_checking_flag = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down Expand Up @@ -97,7 +99,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand Down Expand Up @@ -170,6 +172,17 @@
'Miscellaneous'),
]

# add_module_names = False


def remove_module_docstring(app, what, name, obj, options, lines):
if what == "module" and name == "neural_tangents":
del lines[:]


def setup(app):
app.connect("autodoc-process-docstring", remove_module_docstring)


# -- Options for Epub output -------------------------------------------------

Expand Down
29 changes: 29 additions & 0 deletions docs/empirical.rst
@@ -0,0 +1,29 @@
.. default-role:: code

Empirical -- finite NNGP and NTK
======================================

.. automodule:: neural_tangents._src.empirical
.. currentmodule:: neural_tangents

Kernel functions
--------------------------------------
Finite-width NNGP and/or NTK kernel functions.

.. autosummary::
:toctree: _autosummary

empirical_kernel_fn
empirical_nngp_fn
empirical_ntk_fn


Linearization and Taylor expansion
--------------------------------------
Decorators to Taylor-expand around function parameters.

.. autosummary::
:toctree: _autosummary

linearize
taylor_expand
10 changes: 5 additions & 5 deletions docs/index.rst
Expand Up @@ -8,11 +8,11 @@ neural networks.
:maxdepth: 2
:caption: Topics:

neural_tangents.stax
neural_tangents._src.empirical
neural_tangents.predict
neural_tangents._src.batching
neural_tangents._src.monte_carlo
stax
empirical
predict
batching
monte_carlo

Indices and tables
==================
Expand Down
7 changes: 7 additions & 0 deletions docs/monte_carlo.rst
@@ -0,0 +1,7 @@
Monte Carlo Sampling
======================================

.. default-role:: code
.. automodule:: neural_tangents._src.monte_carlo
.. automodule:: neural_tangents
:members: monte_carlo_kernel_fn
6 changes: 0 additions & 6 deletions docs/neural_tangents.batching.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/neural_tangents.empirical.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/neural_tangents.monte_carlo.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/neural_tangents.predict.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/neural_tangents.stax.rst

This file was deleted.

39 changes: 39 additions & 0 deletions docs/predict.rst
@@ -0,0 +1,39 @@
.. default-role:: code

Predict -- inference with NNGP and NTK or linearized networks
=============================================================

.. automodule:: neural_tangents._src.predict
.. currentmodule:: neural_tangents.predict


Prediction / inference functions
--------------------------------------
Functions to make train/test set predictions given NNGP/NTK kernels or the linearized function.

.. autosummary::
:toctree: _autosummary

gradient_descent
gradient_descent_mse
gradient_descent_mse_ensemble
gp_inference


Utilities
--------------------------------------
.. autosummary::
:toctree: _autosummary

max_learning_rate


Helper classes
--------------------------------------
Dataclasses and namedtuples used to return predictions.

.. autosummary::
:toctree: _autosummary

Gaussian
ODEState
3 changes: 0 additions & 3 deletions docs/requirements.txt
Expand Up @@ -5,6 +5,3 @@ jaxlib
ipykernel
nbsphinx
sphinx-autodoc-typehints
# The next packages are for notebooks
matplotlib
.
115 changes: 115 additions & 0 deletions docs/stax.rst
@@ -0,0 +1,115 @@
.. default-role:: code

Stax -- infinite networks (NNGP, NTK)
======================================

.. automodule:: neural_tangents.stax


Combinators
--------------------------------------
Layers to combine multiple other layers into one.

.. autosummary::
:toctree: _autosummary

serial
parallel


Branching
--------------------------------------
Layers to split outputs into many, or combine many into ones.

.. autosummary::
:toctree: _autosummary

FanOut
FanInConcat
FanInProd
FanInSum


Linear parametric
--------------------------------------
Linear layers with trainable parameters.

.. autosummary::
:toctree: _autosummary

Dense
Conv
ConvLocal
ConvTranspose
GlobalSelfAttention


Linear nonparametric
--------------------------------------
Linear layers without any trainable parameters.

.. autosummary::
:toctree: _autosummary

Aggregate
AvgPool
Identity
DotGeneral
Dropout
Flatten
GlobalAvgPool
GlobalSumPool
ImageResize
LayerNorm
SumPool


Elementwise nonlinear
--------------------------------------
Pointwise nonlinear layers.

.. autosummary::
:toctree: _autosummary

ABRelu
Abs
Cos
Elementwise
ElementwiseNumerical
Erf
Exp
ExpNormalized
Gaussian
Gelu
Hermite
LeakyRelu
Rbf
Relu
Sigmoid_like
Sign
Sin


Helper enums
--------------------------------------
Enums for specifying layer properties. Strings can be used in their place.

.. autosummary::
:toctree: _autosummary

Padding
PositionalEmbedding


For developers
--------------------------------------
Classes and decorators helpful for constructing your own layers.

.. autosummary::
:toctree: _autosummary

layer
supports_masking
requires
Bool
Diagonal

0 comments on commit 22b3aae

Please sign in to comment.