add generated api_doc

This commit is contained in:
iclementine 2020-12-18 10:54:50 +08:00
parent afc476d8c3
commit bbc50faef2
18 changed files with 557 additions and 17 deletions

20
doc/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

35
doc/make.bat Normal file
View File

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

62
doc/source/conf.py Normal file
View File

@ -0,0 +1,62 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'parakeet'
copyright = '2020, parakeet-developers'
author = 'parakeet-developers'
# The full version, including alpha/beta/rc tags
release = '0.2'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
"sphinx_rtd_theme",
'sphinx.ext.napoleon',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# 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']
source_suffix = ['.rst', '.md']
# -- Extension configuration -------------------------------------------------

20
doc/source/index.rst Normal file
View File

@ -0,0 +1,20 @@
.. parakeet documentation master file, created by
sphinx-quickstart on Thu Dec 17 20:01:34 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to parakeet's documentation!
====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

7
doc/source/modules.rst Normal file
View File

@ -0,0 +1,7 @@
parakeet
========
.. toctree::
:maxdepth: 4
parakeet

View File

@ -0,0 +1,29 @@
parakeet.audio package
======================
Submodules
----------
parakeet.audio.audio module
---------------------------
.. automodule:: parakeet.audio.audio
:members:
:undoc-members:
:show-inheritance:
parakeet.audio.spec\_normalizer module
--------------------------------------
.. automodule:: parakeet.audio.spec_normalizer
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.audio
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,29 @@
parakeet.data package
=====================
Submodules
----------
parakeet.data.batch module
--------------------------
.. automodule:: parakeet.data.batch
:members:
:undoc-members:
:show-inheritance:
parakeet.data.dataset module
----------------------------
.. automodule:: parakeet.data.dataset
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.data
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,29 @@
parakeet.datasets package
=========================
Submodules
----------
parakeet.datasets.common module
-------------------------------
.. automodule:: parakeet.datasets.common
:members:
:undoc-members:
:show-inheritance:
parakeet.datasets.ljspeech module
---------------------------------
.. automodule:: parakeet.datasets.ljspeech
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.datasets
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,37 @@
parakeet.frontend package
=========================
Submodules
----------
parakeet.frontend.phonectic module
----------------------------------
.. automodule:: parakeet.frontend.phonectic
:members:
:undoc-members:
:show-inheritance:
parakeet.frontend.punctuation module
------------------------------------
.. automodule:: parakeet.frontend.punctuation
:members:
:undoc-members:
:show-inheritance:
parakeet.frontend.vocab module
------------------------------
.. automodule:: parakeet.frontend.vocab
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.frontend
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,45 @@
parakeet.models package
=======================
Submodules
----------
parakeet.models.tacotron2 module
--------------------------------
.. automodule:: parakeet.models.tacotron2
:members:
:undoc-members:
:show-inheritance:
parakeet.models.transformer\_tts module
---------------------------------------
.. automodule:: parakeet.models.transformer_tts
:members:
:undoc-members:
:show-inheritance:
parakeet.models.waveflow module
-------------------------------
.. automodule:: parakeet.models.waveflow
:members:
:undoc-members:
:show-inheritance:
parakeet.models.wavenet module
------------------------------
.. automodule:: parakeet.models.wavenet
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.models
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,93 @@
parakeet.modules package
========================
Submodules
----------
parakeet.modules.attention module
---------------------------------
.. automodule:: parakeet.modules.attention
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.audio module
-----------------------------
.. automodule:: parakeet.modules.audio
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.cbhg module
----------------------------
.. automodule:: parakeet.modules.cbhg
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.connections module
-----------------------------------
.. automodule:: parakeet.modules.connections
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.conv module
----------------------------
.. automodule:: parakeet.modules.conv
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.geometry module
--------------------------------
.. automodule:: parakeet.modules.geometry
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.losses module
------------------------------
.. automodule:: parakeet.modules.losses
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.masking module
-------------------------------
.. automodule:: parakeet.modules.masking
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.positional\_encoding module
--------------------------------------------
.. automodule:: parakeet.modules.positional_encoding
:members:
:undoc-members:
:show-inheritance:
parakeet.modules.transformer module
-----------------------------------
.. automodule:: parakeet.modules.transformer
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.modules
:members:
:undoc-members:
:show-inheritance:

25
doc/source/parakeet.rst Normal file
View File

@ -0,0 +1,25 @@
parakeet package
================
Subpackages
-----------
.. toctree::
:maxdepth: 4
parakeet.audio
parakeet.data
parakeet.datasets
parakeet.frontend
parakeet.models
parakeet.modules
parakeet.training
parakeet.utils
Module contents
---------------
.. automodule:: parakeet
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,37 @@
parakeet.training package
=========================
Submodules
----------
parakeet.training.cli module
----------------------------
.. automodule:: parakeet.training.cli
:members:
:undoc-members:
:show-inheritance:
parakeet.training.default\_config module
----------------------------------------
.. automodule:: parakeet.training.default_config
:members:
:undoc-members:
:show-inheritance:
parakeet.training.experiment module
-----------------------------------
.. automodule:: parakeet.training.experiment
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.training
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,61 @@
parakeet.utils package
======================
Submodules
----------
parakeet.utils.checkpoint module
--------------------------------
.. automodule:: parakeet.utils.checkpoint
:members:
:undoc-members:
:show-inheritance:
parakeet.utils.display module
-----------------------------
.. automodule:: parakeet.utils.display
:members:
:undoc-members:
:show-inheritance:
parakeet.utils.internals module
-------------------------------
.. automodule:: parakeet.utils.internals
:members:
:undoc-members:
:show-inheritance:
parakeet.utils.layer\_tools module
----------------------------------
.. automodule:: parakeet.utils.layer_tools
:members:
:undoc-members:
:show-inheritance:
parakeet.utils.mp\_tools module
-------------------------------
.. automodule:: parakeet.utils.mp_tools
:members:
:undoc-members:
:show-inheritance:
parakeet.utils.scheduler module
-------------------------------
.. automodule:: parakeet.utils.scheduler
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: parakeet.utils
:members:
:undoc-members:
:show-inheritance:

View File

@ -33,8 +33,7 @@ __all__ = ["TransformerTTS", "TransformerTTSLoss"]
# Transformer TTS's own implementation of transformer
class MultiheadAttention(nn.Layer):
"""
Multihead scaled dot product attention with drop head. See
"""Multihead scaled dot product attention with drop head. See
[Scheduled DropHead: A Regularization Method for Transformer Models](https://arxiv.org/abs/2004.13342)
for details.

View File

@ -25,22 +25,30 @@ def scaled_dot_product_attention(q,
mask=None,
dropout=0.0,
training=True):
"""
scaled dot product attention with mask. Assume q, k, v all have the same
leader dimensions(denoted as * in descriptions below). Dropout is applied to
attention weights before weighted sum of values.
Args:
q (Tensor): shape(*, T_q, d), the query tensor.
k (Tensor): shape(*, T_k, d), the key tensor.
v (Tensor): shape(*, T_k, d_v), the value tensor.
mask (Tensor, optional): shape(*, T_q, T_k) or broadcastable shape, the
mask tensor, 0 correspond to padding. Defaults to None.
"""Scaled dot product attention with masking.
Returns:
(out, attn_weights)
out (Tensor): shape(*, T_q, d_v), the context vector.
attn_weights (Tensor): shape(*, T_q, T_k), the attention weights.
Assume that q, k, v all have the same leading dimensions (denoted as * in
descriptions below). Dropout is applied to attention weights before
weighted sum of values.
Parameters
-----------
q: Tensor [shape=(*, T_q, d)]
the query tensor.
k: Tensor [shape=(*, T_k, d)]
the key tensor.
v: Tensor [shape=(*, T_k, d_v)]
the value tensor.
mask: Tensor, [shape=(*, T_q, T_k) or broadcastable shape], optional
the mask tensor, zeros correspond to paddings. Defaults to None.
Returns
----------
out: Tensor [shape(*, T_q, d_v)]
the context vector.
attn_weights [Tensor shape(*, T_q, T_k)]
the attention weights.
"""
d = q.shape[-1] # we only support imperative execution
qk = paddle.matmul(q, k, transpose_y=True)

View File

@ -0,0 +1,2 @@
from parakeet.training.cli import *
from parakeet.training.experiment import *

View File

@ -25,6 +25,7 @@ from collections import defaultdict
import parakeet
from parakeet.utils import checkpoint, mp_tools
__all__ = ["ExperimentBase"]
class ExperimentBase(object):
"""
@ -41,6 +42,7 @@ class ExperimentBase(object):
Feel free to add/overwrite other methods and standalone functions if you need.
Examples:
--------
def main_sp(config, args):