diff --git a/paddle/fluid/operators/row_conv_op.cc b/paddle/fluid/operators/row_conv_op.cc index f4b540f1cbb1d528ba8dd32ebcf15eb839637816..d7286111fd90be28bb217407f3cc502a331b2799 100644 --- a/paddle/fluid/operators/row_conv_op.cc +++ b/paddle/fluid/operators/row_conv_op.cc @@ -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: diff --git a/paddle/fluid/operators/uniform_random_op.cc b/paddle/fluid/operators/uniform_random_op.cc index 65525526c9a18b7367028c4348636f1871810030..edd1baa4ace4e246190afcd12b0716f1dd38e243 100644 --- a/paddle/fluid/operators/uniform_random_op.cc +++ b/paddle/fluid/operators/uniform_random_op.cc @@ -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]. diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index fe60d8b78d46b95ccfb00266509769d964723f44..f1241d9479200bb0eb6317d50925455196aba613 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -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() diff --git a/python/paddle/fluid/layers/ops.py b/python/paddle/fluid/layers/ops.py index 98f169e8f0881fbba6aecb45b43a52c8fd51132d..46c6fd686e0b217da03c8110c3cbb9f54efddda6 100644 --- a/python/paddle/fluid/layers/ops.py +++ b/python/paddle/fluid/layers/ops.py @@ -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]) +""" diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index 241bbe78bd52b093df19e6fdce39842b8f8d7899..04efc40af5ef36a81ef23f537130d8ca54d73365 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -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: