未验证 提交 5d334ff0 编写于 作者: G gongweibao 提交者: GitHub

Add examples to some functions. (#14645)

上级 4b761774
......@@ -7606,6 +7606,11 @@ def uniform_random_batch_size_like(input,
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
input = layers.data(name="input", shape=[13, 11], dtype='float32')
out = layers.uniform_random_batch_size_like(input, [-1, 11])
"""
helper = LayerHelper('uniform_random_batch_size_like', **locals())
......@@ -7643,6 +7648,10 @@ def gaussian_random(shape, mean=0.0, std=1.0, seed=0, dtype='float32'):
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
out = layers.gaussian_random(shape=[20, 30])
"""
helper = LayerHelper('gaussian_random', **locals())
......@@ -7678,6 +7687,16 @@ def sampling_id(x, min=0.0, max=1.0, seed=0, dtype='float32'):
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
x = layers.data(
name="X",
shape=[13, 11],
dtype='float32',
append_batch_size=False)
out = layers.sampling_id(x)
"""
helper = LayerHelper('sampling_id', **locals())
......@@ -7717,6 +7736,14 @@ def gaussian_random_batch_size_like(input,
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
input = layers.data(name="input", shape=[13, 11], dtype='float32')
out = layers.gaussian_random_batch_size_like(
input, shape=[-1, 11], mean=1.0, std=2.0)
"""
helper = LayerHelper('gaussian_random_batch_size_like', **locals())
......@@ -7749,6 +7776,12 @@ def sum(x):
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
input = layers.data(name="input", shape=[13, 11], dtype='float32')
out = layers.sum(input)
"""
helper = LayerHelper('sum', **locals())
......@@ -7777,6 +7810,17 @@ def slice(input, axes, starts, ends):
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
starts = [1, 0, 2]
ends = [3, 3, 4]
axes = [0, 1, 2]
input = layers.data(
name="input", shape=[3, 4, 5, 6], dtype='float32')
out = layers.slice(input, axes=axes, starts=starts, ends=ends)
"""
helper = LayerHelper('slice', **locals())
......@@ -7804,6 +7848,12 @@ def shape(input):
Returns:
out (Variable): ${out_comment}
Examples:
.. code-block:: python
input = layers.data(
name="input", shape=[3, 100, 100], dtype="float32")
out = layers.shape(input)
"""
helper = LayerHelper('shape', **locals())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册