Skip to content

Commit 32b3841

Browse files
vishwakftwsoumith
authored andcommitted
[ready] General documentation improvements (pytorch#5450)
* Improvize documentation 1. Add formula for erf, erfinv 2. Make exp, expm1 similar to log, log1p 3. Symbol change in ge, le, ne, isnan * Fix minor nit in the docstring * More doc improvements 1. Added some formulae 2. Complete scanning till "Other Operations" in Tensor docs * Add more changes 1. Modify all torch.Tensor wherever required * Fix Conv docs 1. Fix minor nits in the references for LAPACK routines * Improve Pooling docs 1. Fix lint error * Improve docs for RNN, Normalization and Padding 1. Fix flake8 error for pooling * Final fixes for torch.nn.* docs. 1. Improve Loss Function documentation 2. Improve Vision Layers documentation * Fix lint error * Improve docstrings in torch.nn.init * Fix lint error * Fix minor error in torch.nn.init.sparse * Fix Activation and Utils Docs 1. Fix Math Errors 2. Add explicit clean to Makefile in docs to prevent running graph generation script while cleaning 3. Fix utils docs * Make PYCMD a Makefile argument, clear up prints in the build_activation_images.py * Fix batch norm doc error
1 parent c16478f commit 32b3841

27 files changed

+945
-610
lines changed

docs/Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ SPHINXBUILD = sphinx-build
77
SPHINXPROJ = PyTorch
88
SOURCEDIR = source
99
BUILDDIR = build
10+
PYCMD = python
1011

1112
# Put it first so that "make" without argument is like "make help".
1213
help:
1314
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1415

1516
figures:
16-
python source/scripts/build_activation_images.py
17+
@$(PYCMD) source/scripts/build_activation_images.py
1718

1819
docset: html
1920
doc2dash --name $(SPHINXPROJ) --icon $(SOURCEDIR)/_static/img/pytorch-logo-flame.png --enable-js --online-redirect-url http://pytorch.org/docs/ --force $(BUILDDIR)/html/
@@ -28,3 +29,7 @@ docset: html
2829
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2930
%: Makefile figures
3031
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
32+
33+
clean:
34+
@echo "Removing everything under 'build'.."
35+
@rm -r $(BUILDDIR)/html/ $(BUILDDIR)/doctrees

docs/source/scripts/build_activation_images.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def plot_function(function, **args):
6767
plot_path = os.path.join(ACTIVATION_IMAGE_PATH, function_name + ".png")
6868
if not os.path.exists(plot_path):
6969
function = torch.nn.modules.activation.__dict__[function_name]()
70-
print(function)
7170

7271
# Start a new plot
7372
pylab.clf()
@@ -91,5 +90,5 @@ def plot_function(function, **args):
9190
pylab.ylim([-7, 7])
9291

9392
# And save it
94-
print(plot_path)
9593
pylab.savefig(plot_path)
94+
print('Saved activation image for {} at {}'.format(function, plot_path))

torch/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def typename(o):
110110

111111

112112
def is_tensor(obj):
113-
r"""Returns True if `obj` is a pytorch tensor.
113+
r"""Returns True if `obj` is a PyTorch tensor.
114114
115115
Args:
116116
obj (Object): Object to test
@@ -119,7 +119,7 @@ def is_tensor(obj):
119119

120120

121121
def is_storage(obj):
122-
r"""Returns True if `obj` is a pytorch storage object.
122+
r"""Returns True if `obj` is a PyTorch storage object.
123123
124124
Args:
125125
obj (Object): Object to test

torch/_storage_docs.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ def add_docstr_all(method, docstr):
2828
"""
2929
from_file(filename, shared=False, size=0) -> Storage
3030
31-
If shared is True then memory is shared between all processes. All changes are
32-
written to the file. If shared is False then the changes on the storage do not
33-
affect the file.
34-
35-
Size is the number of elements in the storage. If shared is False then the file
36-
must contain at least `size * sizeof(Type)` bytes (`Type` is the type of
37-
storage). If shared is True the file will be created if needed.
31+
If `shared` is `True`, then memory is shared between all processes.
32+
All changes are written to the file. If `shared` is `False`, then the changes on
33+
the storage do not affect the file.
34+
35+
`size` is the number of elements in the storage. If `shared` is `False`,
36+
then the file must contain at least `size * sizeof(Type)` bytes
37+
(`Type` is the type of storage). If `shared` is `True` the file will be
38+
created if needed.
3839
3940
Args:
4041
filename (str): file name to map

torch/_tensor_docs.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def add_docstr_all(method, docstr):
259259
260260
.. math::
261261
262-
P(x) = \dfrac{1}{\pi} \dfrac{\sigma}{(x - median)^2 + \sigma^2}
262+
f(x) = \dfrac{1}{\pi} \dfrac{\sigma}{(x - median)^2 + \sigma^2}
263263
""")
264264

265265
add_docstr_all('ceil',
@@ -514,7 +514,7 @@ def add_docstr_all(method, docstr):
514514
515515
.. math::
516516
517-
P(x) = \lambda e^{-\lambda x}
517+
f(x) = \lambda e^{-\lambda x}
518518
""")
519519

520520
add_docstr_all('fill_',
@@ -602,7 +602,7 @@ def add_docstr_all(method, docstr):
602602
603603
.. math::
604604
605-
P(X=k) = (1 - p)^{k - 1} p
605+
f(X=k) = (1 - p)^{k - 1} p
606606
607607
""")
608608

@@ -861,7 +861,7 @@ def add_docstr_all(method, docstr):
861861
862862
.. math::
863863
864-
P(x) = \\dfrac{1}{x \\sigma \\sqrt{2\\pi}}\ e^{-\\dfrac{(\\ln x - \\mu)^2}{2\\sigma^2}}
864+
f(x) = \\dfrac{1}{x \\sigma \\sqrt{2\\pi}}\ e^{-\\dfrac{(\\ln x - \\mu)^2}{2\\sigma^2}}
865865
""")
866866

867867
add_docstr_all('lt',

torch/_tensor_str.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ def set_printoptions(
2323
linewidth=None,
2424
profile=None,
2525
):
26-
"""Set options for printing. Items shamelessly taken from Numpy
26+
r"""Set options for printing. Items shamelessly taken from NumPy
2727
2828
Args:
2929
precision: Number of digits of precision for floating point output
30-
(default 8).
30+
(default = 8).
3131
threshold: Total number of array elements which trigger summarization
32-
rather than full repr (default 1000).
32+
rather than full `repr` (default = 1000).
3333
edgeitems: Number of array items in summary at beginning and end of
34-
each dimension (default 3).
34+
each dimension (default = 3).
3535
linewidth: The number of characters per line for the purpose of
36-
inserting line breaks (default 80). Thresholded matricies will
36+
inserting line breaks (default = 80). Thresholded matricies will
3737
ignore this parameter.
3838
profile: Sane defaults for pretty printing. Can override with any of
39-
the above options. (default, short, full)
39+
the above options. (any one of `default`, `short`, `full`)
4040
"""
4141
if profile is not None:
4242
if profile == "default":

0 commit comments

Comments
 (0)