Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding API docs for ones and zeros methods #7150

Merged
merged 1 commit into from
Jan 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions python/paddle/v2/fluid/layers/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,47 @@ def fill_constant_batch_size_like(input,

def ones(shape, dtype):
"""
This function performs the same function as fill_constant() declared above
with the constant value being 1.0.
**ones**

This function creates a tensor of specified *shape* and
*dtype*, and initializes this with 1.

It also sets *stop_gradient* to True.

Args:
shape(tuple|list|None): Shape of output tensor
dtype(np.dtype|core.DataType|str): Data type of output tensor

Returns:
Variable: The tensor variable storing the output

Examples:
.. code-block:: python

data = fluid.layers.ones(shape=[1], dtype='int64')
"""
return fill_constant(value=1.0, **locals())


def zeros(shape, dtype):
"""
This function performs the same function as fill_constant() declared above
with the constant value being 0.0.
**zeros**

This function creates a tensor of specified *shape* and
*dtype*, and initializes this with 0.

It also sets *stop_gradient* to True.

Args:
shape(tuple|list|None): Shape of output tensor
dtype(np.dtype|core.DataType|str): Data type of output tensor

Returns:
Variable: The tensor variable storing the output

Examples:
.. code-block:: python

data = fluid.layers.zeros(shape=[1], dtype='int64')
"""
return fill_constant(value=0.0, **locals())