From 5d334ff0f158955f6fb9069f37183ccf3d4e496f Mon Sep 17 00:00:00 2001 From: gongweibao Date: Fri, 30 Nov 2018 09:48:45 +0800 Subject: [PATCH] Add examples to some functions. (#14645) --- python/paddle/fluid/layers/nn.py | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 56366142eb7..04037651213 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -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()) -- GitLab