Skip to content

Commit

Permalink
bindings/python/doc: fix most Sphinx warnings and some misc. errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mahilleb-msft committed Mar 15, 2017
1 parent 10dbd2f commit ec76e43
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion bindings/python/cntk/debugging/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def save_as_legacy_model(root_op, filename):
For debugging purposes only, very likely to be deprecated in the future.
Args:
root_op (:class:`~cntk.functions.Function`): op of the graph to save
root_op (:class:`~cntk.ops.functions.Function`): op of the graph to save
filename (str): filename to store the model in.
'''
cntk_py.save_as_legacy_model(root_op, filename)
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/cntk/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def uniform(scale, seed=None):
seed (int): random seed
Returns:
initializer for :class:`cntk.variables.Parameter`
initializer for :class:`cntk.ops.variables.Parameter`
initialized to uniform distribution between `scale*[-1.0, 1.0]`
note this maps to the "uniform1" distribution in BrainScript.
'''
Expand All @@ -38,7 +38,7 @@ def normal(scale, output_rank=SentinelValueForInferParamInitRank, filter_rank=Se
seed (int): random seed
Returns:
initializer for :class:`cntk.variables.Parameter`
initializer for :class:`cntk.ops.variables.Parameter`
initialized to normal distribution with mean `0` and standard deviation `scale`.
'''
if seed is None:
Expand Down
10 changes: 5 additions & 5 deletions bindings/python/cntk/internal/sanitize.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def sanitize_batch(var, batch, seq_starts=None, device=None):

def sanitize_value(shape, value, dtype, device):
'''
Converts a given ``value`` to an :class:`~cntk.NDArrayView` object that can be passed to
Converts a given ``value`` to an :class:`~cntk.core.NDArrayView` object that can be passed to
the CNTK core.
Args:
Expand All @@ -169,7 +169,7 @@ def sanitize_value(shape, value, dtype, device):
on
Returns:
:class:`~cntk.NDArrayView` object representing ``value``
:class:`~cntk.core.NDArrayView` object representing ``value``
'''
from .. import NDArrayView
if value is None:
Expand Down Expand Up @@ -216,8 +216,8 @@ def sanitize_var_map(op_arguments, arguments, precision=None,
handed off to the evaluation methods
(:meth:`~cntk.ops.functions.Function.forward`,
:meth:`~cntk.ops.functions.Function.backward`,
:meth:`~cntk.Trainer.train_minibatch` and
:meth:`~cntk.Trainer.test_minibatch`).
:meth:`~cntk.train.trainer.Trainer.train_minibatch` and
:meth:`~cntk.train.trainer.Trainer.test_minibatch`).
Args:
op_arguments (:class:`~cntk.ops.functions.Function`): arguments of the
Expand Down Expand Up @@ -264,7 +264,7 @@ def sanitize_var_map(op_arguments, arguments, precision=None,
map are converted to the underlying value (:class:`~cntk.core.Value`)
instances (default), or if they should remain intact, as they contain
additional meta information required by the Trainer (specifically, by
the :meth:`~cntk.Trainer.train_minibatch` method).
the :meth:`~cntk.train.trainer.Trainer.train_minibatch` method).
Returns:
`dict` that maps variables to sanitized batches
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/cntk/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class MinibatchSource(cntk_py.MinibatchSource):
A `MinibatchSource` can be indexed by the stream name, which will return a
Parent class of all minibatch sources. A `MinibatchSource` can be indexed by the stream name, which will return a
:class:`MinibatchData` object that can be passed e.g. to the
:func:`~cntk.trainer.Trainer.train_minibatch` function.
:func:`~cntk.train.trainer.Trainer.train_minibatch` function.
Args:
deserializers (`list`, defaults to empty): list of deserializers
Expand Down Expand Up @@ -366,7 +366,7 @@ def minibatch_source(self):
'''
Creates an instance of :class:`MinibatchSource` from this
instance, which can be used to feed data into the `eval()` methods of
the graph nodes or the `train_minibatch()` of :class:`~cntk.trainer.Trainer`.
the graph nodes or the `train_minibatch()` of :class:`~cntk.train.trainer.Trainer`.
Returns:
cntk.io.MinibatchSource:
Expand Down
20 changes: 10 additions & 10 deletions bindings/python/cntk/learners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def sgd(parameters, lr,
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the :class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the :class:`~cntk.train.trainer.Trainer`
See also:
[1] L. Bottou. `Stochastic Gradient Descent Tricks
Expand Down Expand Up @@ -479,8 +479,8 @@ def momentum_sgd(parameters, lr, momentum, unit_gain=default_unit_gain_value(),
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the
:class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the
:class:`~cntk.train.trainer.Trainer`
'''
_verify_learning_rate_type(lr)
_verify_momentum_type(momentum)
Expand Down Expand Up @@ -530,8 +530,8 @@ def nesterov(parameters, lr, momentum, unit_gain=default_unit_gain_value(),
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the
:class:`~cntk.trainer.Trainer`.
Instance of a :class:`~cntk.learners.Learner` that can be passed to the
:class:`~cntk.train.trainer.Trainer`.
See also:
[1] Y. Nesterov. A Method of Solving a Convex Programming Problem with Convergence Rate O(1/ sqrt(k)). Soviet Mathematics Doklady, 1983.
Expand Down Expand Up @@ -585,7 +585,7 @@ def adagrad(parameters, lr, need_ave_multiplier=True,
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the :class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the :class:`~cntk.train.trainer.Trainer`
See also:
[1] J. Duchi, E. Hazan, and Y. Singer. `Adaptive Subgradient Methods
Expand Down Expand Up @@ -641,7 +641,7 @@ def fsadagrad(parameters, lr, momentum, unit_gain=default_unit_gain_value(),
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the :class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the :class:`~cntk.train.trainer.Trainer`
'''
_verify_learning_rate_type(lr)
Expand Down Expand Up @@ -695,7 +695,7 @@ def adam(parameters, lr, momentum, unit_gain=default_unit_gain_value(),
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the :class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the :class:`~cntk.train.trainer.Trainer`
See also:
[1] D. Kingma, J. Ba. `Adam: A Method for Stochastic Optimization
Expand Down Expand Up @@ -757,7 +757,7 @@ def adam_sgd(parameters, lr, momentum, unit_gain=default_unit_gain_value(),
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the :class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the :class:`~cntk.train.trainer.Trainer`
See also:
[1] D. Kingma, J. Ba. `Adam: A Method for Stochastic Optimization
Expand Down Expand Up @@ -814,7 +814,7 @@ def rmsprop(parameters, lr,
with truncation
Returns:
Instance of a :class:`~cntk.learner.Learner` that can be passed to the :class:`~cntk.trainer.Trainer`
Instance of a :class:`~cntk.learners.Learner` that can be passed to the :class:`~cntk.train.trainer.Trainer`
'''
_verify_learning_rate_type(lr)
gaussian_noise_injection_std_dev = \
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/cntk/logging/progress_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def update_with_trainer(self, trainer, with_metric=False):
``trainer``.
Args:
trainer (:class:`cntk.trainer.Trainer`): trainer from which information is gathered
trainer (:class:`cntk.train.trainer.Trainer`): trainer from which information is gathered
with_metric (`bool`): whether to update the metric accumulators
'''
if self.total_updates == 0:
Expand Down Expand Up @@ -421,7 +421,7 @@ class TensorBoardProgressWriter(cntk_py.ProgressWriter):
log_dir (`string`, default '.'): directory where to create a TensorBoard event file.
rank (`int` or `None`, default `None`): rank of a worker when using distributed training, or `None` if
training locally. If not `None`, event files will be created only by rank 0.
model (:class:`cntk.ops.Function` or `None`, default `None`): model graph to plot.
model (:class:`cntk.ops.functions.Function` or `None`, default `None`): model graph to plot.
'''

def __init__(self, freq=None, log_dir='.', rank=None, model=None):
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/cntk/ops/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ def infer_outputs(self):
outputs.
Output variables are created by
:meth:`~cntk.ops.functions.output_variable`.
:meth:`~cntk.ops.output_variable`.
'''
raise NotImplementedError('infer_outputs has to be overwritten')

Expand Down
8 changes: 4 additions & 4 deletions bindings/python/cntk/train/training_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ..io import _py_dict_to_cntk_dict

__doc__ = '''\
A training session encapsulates a typical training loop and binds together a minibatch source that is used for training, a :doc:`trainer <cntk.trainer>` and an optional cross validation minibatch source. A training session takes care of consistent checkpointing and progress printing with specified frequencies.
A training session encapsulates a typical training loop and binds together a minibatch source that is used for training, a :doc:`trainer <cntk.train.trainer>` and an optional cross validation minibatch source. A training session takes care of consistent checkpointing and progress printing with specified frequencies.
'''
class CheckpointConfig(cntk_py.CheckpointConfig):
'''
Expand Down Expand Up @@ -94,14 +94,14 @@ def __init__(self, source=None, mb_size=None, frequency=None, callback=None):

class TrainingSession(cntk_py.TrainingSession):
'''
The instance of the class should be created by using :func:`~cntk.training_session.training_session` function.
The instance of the class should be created by using :func:`~cntk.train.training_session.training_session` function.
A training session trains a model using the specified ``trainer`` and configs.
Different aspects of training such as data sources, checkpointing, cross validation, progress printing
can be configured using the corresponding config classes.
Args:
trainer (:class:`~cntk.trainer.Trainer`): trainer
trainer (:class:`~cntk.train.trainer.Trainer`): trainer
mb_source (:class:`~cntk.io.MinibatchSource`): minibatch source used for training
mb_size (:class:`~cntk.cntk_py.minibatch_size_schedule` or int): minibatch size schedule for training
var_to_stream (dict): mapping between input variables and input streams
Expand Down Expand Up @@ -256,7 +256,7 @@ def training_session(training_minibatch_source=None, # deprecated, will b
Args:
training_minibatch_source (:class:`~cntk.io.MinibatchSource`): !DEPRECATED! use mb_source instead
trainer (:class:`~cntk.trainer.Trainer`): trainer
trainer (:class:`~cntk.train.trainer.Trainer`): trainer
mb_size_schedule (:class:`~cntk.cntk_py.minibatch_size_schedule`): !DEPRECATED! use mb_size instead
progress_printer (list): !DEPRECATED! list of progress writers from :mod:`cntk.utils`
model_inputs_to_mb_source_mapping (dict): !DEPRECATED! use var_to_stream instead
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/cntk/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_train_loss(trainer):
Fetch the train loss from the last minibatch and copy it to the CPU in case it is on the GPU.
Args:
trainer (:class:`~cntk.trainer.Trainer`): the trainer used.
trainer (:class:`~cntk.train.trainer.Trainer`): the trainer used.
Returns:
the loss value
'''
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/doc/extend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ debugging mode and can start inspection.
User learners
-------------
Implementing a custom learner in pure Python is accomplished by
- creating a class that inherits from :class:`cntk.learner.UserLearner`
- implementing its :meth:`~cntk.learner.UserLearner.update` method
- creating a class that inherits from :class:`cntk.learners.UserLearner`
- implementing its :meth:`~cntk.learners.UserLearner.update` method

Here is an example, how normal stochastic gradient descent would be
reimplemented in a naive way::
Expand Down
46 changes: 23 additions & 23 deletions bindings/python/doc/layerref.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Layers Library Reference
========================

Note: This documentation has not yet been completely updated w.r.t. the latest update of the Layers library.
It should be correct but miss several new options and layer types.
Note: This documentation has not yet been completely updated with respect to the latest update of the Layers library.
It should be correct but misses several new options and layer types.

CNTK predefines a number of common "layers," which makes it very easy to
write simple networks that consist of standard layers layered on top of
each other. Layers are function objects that can be used like a regular
:class:`~cntk.ops.functions.Function` but hold learnable parameters
and have an additional pair of ``()`` to pass construction parameters
:class:`~cntk.ops.functions.Function` but hold learnable parameters
and have an additional pair of ``()`` to pass construction parameters
or attributes.

For example, this is the network description for a simple 1-hidden layer
Expand Down Expand Up @@ -43,7 +43,7 @@ and invoke it like this:

p = my_model(features)

Built on top of ``Sequential()`` is :ref:`layerstack`,
Built on top of ``Sequential()`` is :ref:`for`,
which allows to easily create models with repetitions. For example, a
2011-style feed-forward speech-recognition network with 6 hidden sigmoid
layers of identical dimensions can be written like this:
Expand Down Expand Up @@ -82,13 +82,13 @@ to define scopes with locally changed defaults, using one of the following two f
with default_options_for(FUNCTION, OPT1=VAL1, OPT2=VAL2, ...):
# scope with modified defaults for FUNCTION only

The following options can be overridden with the ``with`` statement:
The following options can be overridden with the ``with`` statement:

- ``init`` (default: ``glorot_uniform()``): initializer specification, for :ref:`dense`, :ref:`convolution`, and :ref:`embedding`
- ``activation`` (default: ``None``): activation function, for ``Dense()`` and ``Convolution()``
- ``init`` (default: ``glorot_uniform()``): initializer specification, for :ref:`dense`, :ref:`convolution`, and :ref:`embedding`
- ``activation`` (default: ``None``): activation function, for ``Dense()`` and ``Convolution()``
- ``bias`` (default: ``True``): have a bias, for ``Dense()`` and ``Convolution()``
- ``init_bias`` (default: ``0``): initializer specification for the bias, for ``Dense()`` and ``Convolution()``
- ``initial_state`` (default: ``None``): initial state to use in ``Recurrence()`` :ref:`recurrence`
- ``init_bias`` (default: ``0``): initializer specification for the bias, for ``Dense()`` and ``Convolution()``
- ``initial_state`` (default: ``None``): initial state to use in ``Recurrence()`` :ref:`recurrence`
- ``use_peepholes`` (default: ``False``): use peephole connections in ``LSTM()`` :ref:`lstm`

The second for allows to set default options on a
Expand Down Expand Up @@ -242,7 +242,7 @@ Description
Use these factory functions to create a fully-connected layer. It
creates a function object that contains a learnable weight matrix and,
unless ``bias=False``, a learnable bias. The function object can be used
like a function, which implements one of these formulas (using Python
like a function, which implements one of these formulas (using Python
3.5 ``@`` operator for matrix multiplication):

::
Expand Down Expand Up @@ -515,12 +515,12 @@ Description
~~~~~~~~~~~

Use this factory function to create a global pooling operation. Use
``GlobalMaxPooling()`` to compute the maximum over all spatial data,
``GlobalMaxPooling()`` to compute the maximum over all spatial data,
or ``GlobalAveragePooling()`` to take their average.

The global pooling operation infer the pooling window shape from the input
The global pooling operation infer the pooling window shape from the input
tensor and create a pooling function with pooling window size that
matches the input spatial dimension. It then computes either the
matches the input spatial dimension. It then computes either the
maximum or the average of all the values inside the inferred pooling
window.

Expand All @@ -529,7 +529,7 @@ Example:

::

p = GlobalMaxPooling()(c)
p = GlobalMaxPooling()(c)

Dropout()
------------------------------
Expand All @@ -544,7 +544,7 @@ Parameters
~~~~~~~~~~

- ``dropout_rate``: a fraction between [0, 1) that specifies the probability by which
the dropout operation will randomly set elements of the input to zero. 0 mean
the dropout operation will randomly set elements of the input to zero. 0 mean
select everything and close to 1 mean drop every element.

Return Value
Expand All @@ -555,15 +555,15 @@ A function that implements the desired dropout layer.
Description
~~~~~~~~~~~

Use this factory function to create a dropout operation with a specific
Use this factory function to create a dropout operation with a specific
dropout rate.

Example:
~~~~~~~~

::

p = Dropout(0.5)(c)
p = Dropout(0.5)(c)

.. _embedding:

Expand Down Expand Up @@ -1035,7 +1035,7 @@ The ``FGH`` function defined above means the same as

::

y = H(G(F(x)))
y = H(G(F(x)))

This is known as `function
composition <https://en.wikipedia.org/wiki/Function_composition>`_,
Expand Down Expand Up @@ -1081,10 +1081,10 @@ deep-neural network work on speech recognition:

my_model = Sequential ([
Dense(2048, activation=sigmoid), # four hidden layers
Dense(2048, activation=sigmoid),
Dense(2048, activation=sigmoid),
Dense(2048, activation=sigmoid),
Dense(9000, activation=softmax) # note: last layer is a softmax
Dense(2048, activation=sigmoid),
Dense(2048, activation=sigmoid),
Dense(2048, activation=sigmoid),
Dense(9000, activation=softmax) # note: last layer is a softmax
)
features = Input(40)
p = my_model(features)
Expand Down

0 comments on commit ec76e43

Please sign in to comment.