提交 ce6394ed 编写于 作者: Y yuyang18

Polish example

上级 b9843abb
......@@ -114,7 +114,7 @@ and a filter ($W$) of size $context \times d$,
the output sequence is convolved as:
$$
out_{i, :} = \sum_{j=i}^{i + context} in_{j,:} \dot W_{i-j, :}
out_{i, :} = \\sum_{j=i}^{i + context} in_{j,:} \\cdot W_{i-j, :}
$$
In the above equation:
......
......@@ -88,8 +88,6 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker {
void Make() override {
AddOutput("Out", "The output tensor of uniform random op");
AddComment(R"DOC(
Uniform random operator.
This operator initializes a tensor with random values sampled from a
uniform distribution. The random result is in set [min, max].
......
......@@ -1718,10 +1718,14 @@ def layer_norm(input,
h & = f(\\frac{g}{\\sigma}(a - \\mu) + b)
>>> import paddle.fluid as fluid
>>> data = fluid.layers.data(name='data', shape=[3, 32, 32],
>>> dtype='float32')
>>> x = fluid.layers.layer_norm(input=data, begin_norm_axis=1)
* :math:`a`: the vector representation of the summed inputs to the neurons
in that layer.
* :math:`H`: the number of hidden units in a layers
* :math:`g`: the trainable scale parameter.
* :math:`b`: the trainable bias parameter.
Args:
input(Variable): The input tensor variable.
......@@ -1742,6 +1746,12 @@ def layer_norm(input,
Returns:
${y_comment}
Examples:
>>> data = fluid.layers.data(name='data', shape=[3, 32, 32],
>>> dtype='float32')
>>> x = fluid.layers.layer_norm(input=data, begin_norm_axis=1)
"""
helper = LayerHelper('layer_norm', **locals())
dtype = helper.input_dtype()
......@@ -3262,12 +3272,6 @@ def row_conv(input, future_context_size, param_attr=None, act=None):
"""
${comment}
>>> import paddle.fluid as fluid
>>> x = fluid.layers.data(name='x', shape=[16],
>>> dtype='float32', lod_level=1)
>>> out = fluid.layers.row_conv(input=x, future_context_size=2)
Args:
input (${x_type}): ${x_comment}.
future_context_size (int): Future context size. Please note, the shape
......@@ -3278,6 +3282,12 @@ def row_conv(input, future_context_size, param_attr=None, act=None):
Returns:
${out_comment}.
Examples:
>>> import paddle.fluid as fluid
>>> x = fluid.layers.data(name='x', shape=[16],
>>> dtype='float32', lod_level=1)
>>> out = fluid.layers.row_conv(input=x, future_context_size=2)
"""
helper = LayerHelper('row_conv', **locals())
dtype = helper.input_dtype()
......
......@@ -64,7 +64,6 @@ __all__ = [
'logical_or',
'logical_xor',
'logical_not',
'uniform_random',
'uniform_random_batch_size_like',
'gaussian_random',
'gaussian_random_batch_size_like',
......@@ -79,3 +78,23 @@ __all__ = [
for _OP in set(__all__):
globals()[_OP] = generate_layer_fn(_OP)
__all__ += ["uniform_random"]
_uniform_random_ = generate_layer_fn('uniform_random')
def uniform_random(shape, dtype=None, min=None, max=None, seed=None):
kwargs = dict()
for name in locals():
val = locals()[name]
if val is not None:
kwargs[name] = val
return _uniform_random_(**kwargs)
uniform_random.__doc__ = _uniform_random_.__doc__ + "\n"\
+"""
Examples:
>>> result = fluid.layers.uniform_random(shape=[32, 784])
"""
......@@ -6,7 +6,7 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# Unlessf required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
......@@ -57,12 +57,6 @@ def create_parameter(shape,
NOTE: this is a very low-level API. This API is useful when you create
operator by your self. instead of using layers.
>>> import paddle.fluid as fluid
>>> W = fluid.layers.create_parameter(shape=[784, 200], dtype='float32')
>>> data = fluid.layers.data(name="img", shape=[64, 784],
>>> append_batch_size=False)
>>> hidden = fluid.layers.matmul(x=data, y=W)
Args:
shape(list[int]): shape of the parameter
dtype(string): element type of the parameter
......@@ -74,7 +68,12 @@ def create_parameter(shape,
default_initializer(Initializer): initializer for the parameter
Returns:
the created parameter
the created parameter.
Examples:
>>> W = fluid.layers.create_parameter(shape=[784, 200], dtype='float32')
>>> data = fluid.layers.data(name="img", shape=[64, 784], append_batch_size=False)
>>> hidden = fluid.layers.matmul(x=data, y=W)
"""
helper = LayerHelper("create_parameter", **locals())
if attr is None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册