Commit 82afb459 authored by Yuxin Wu's avatar Yuxin Wu

improve documents

parent 01c25a9f
......@@ -14,6 +14,7 @@
import sys, os, re
import mock
import inspect
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
......@@ -339,15 +340,29 @@ def process_signature(app, what, name, obj, options, signature,
# replace Mock function names
signature = re.sub('<Mock name=\'([^\']+)\'.*>', '\g<1>', signature)
signature = re.sub('tensorflow', 'tf', signature)
# add scope name to layer signatures:
if hasattr(obj, 'use_scope') and hasattr(obj, 'symbolic_function'):
if obj.use_scope:
signature = signature[0] + 'name, ' + signature[1:]
# signature: arg list
return signature, return_annotation
def autodoc_skip_member(app, what, name, obj, skip, options):
if name in ['get_data', 'size', 'reset_state']:
# skip these methods with empty docstring
if not obj.__doc__ and inspect.isfunction(obj):
# https://stackoverflow.com/questions/3589311/get-defining-class-of-unbound-method-object-in-python-3
cls = getattr(inspect.getmodule(obj),
obj.__qualname__.split('.<locals>', 1)[0].rsplit('.', 1)[0])
if issubclass(cls, tensorpack.DataFlow):
return True
return None
def setup(app):
from recommonmark.transform import AutoStructify
app.connect('autodoc-process-signature', process_signature)
app.connect('autodoc-skip-member', autodoc_skip_member)
app.add_config_value(
'recommonmark_config',
{'url_resolver': lambda url: \
......
......@@ -3,7 +3,7 @@ numpy
tqdm
decorator
tensorflow
Sphinx>=1.5.1
Sphinx>=1.6
recommonmark==0.4.0
sphinx_rtd_theme
mock
......@@ -108,7 +108,7 @@ class PrefetchDataZMQ(ProxyDataFlow):
communication.
A local directory is needed to put the ZMQ pipes.
You can set this with env var $TENSORPACK_PIPEDIR if you're running on non-local FS such as NFS or GlusterFS.
You can set this with env var ``$TENSORPACK_PIPEDIR`` if you're running on non-local FS such as NFS or GlusterFS.
Note that this dataflow is not fork-safe. You cannot nest this dataflow
into another PrefetchDataZMQ or PrefetchData.
......
......@@ -87,8 +87,7 @@ def BatchNorm(x, use_local_stat=None, decay=0.9, epsilon=1e-5,
Variable Names:
* ``beta``: the bias term. Will be zero-inited by default.
* ``gamma``: the scale term. Will be one-inited by default.
Input will be transformed by ``x * gamma + beta``.
* ``gamma``: the scale term. Will be one-inited by default. Input will be transformed by ``x * gamma + beta``.
* ``mean/EMA``: the moving average of mean.
* ``variance/EMA``: the moving average of variance.
......
......@@ -11,7 +11,6 @@ import copy
from ..tfutils.argscope import get_arg_scope
from ..tfutils.model_utils import get_shape_str
from ..utils import logger
# from ..utils.develop import building_rtfd
# make sure each layer is only logged once
_LAYER_LOGGED = set()
......@@ -147,9 +146,4 @@ def layer_register(
_register(func.__name__, wrapped_func)
return wrapped_func
# if building_rtfd():
# # preserve argspec
# from decorator import decorator
# wrapper = decorator(wrapper)
return wrapper
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment