From f0dabe680d8bb2a694a62f2d63bb6b81f778b110 Mon Sep 17 00:00:00 2001 From: lijianshe02 <48898730+lijianshe02@users.noreply.github.com> Date: Fri, 11 Oct 2019 16:32:14 +0800 Subject: [PATCH] fix read_file, is_empty, Print API EN doc (#20492) * fix Print, is_empty, read_file test=document_fix --- paddle/fluid/API.spec | 6 ++--- python/paddle/fluid/layers/control_flow.py | 27 ++++++++++------------ python/paddle/fluid/layers/io.py | 4 ++-- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 20be1488ad3..c67734977d4 100755 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -309,7 +309,7 @@ paddle.fluid.layers.hard_swish (ArgSpec(args=['x', 'threshold', 'scale', 'offset paddle.fluid.layers.mse_loss (ArgSpec(args=['input', 'label'], varargs=None, keywords=None, defaults=None), ('document', 'd9ede6469288636e1b3233b461a165c9')) paddle.fluid.layers.uniform_random (ArgSpec(args=['shape', 'dtype', 'min', 'max', 'seed'], varargs=None, keywords=None, defaults=('float32', -1.0, 1.0, 0)), ('document', '126ede8ce0e751244b1b54cd359c89d7')) paddle.fluid.layers.data (ArgSpec(args=['name', 'shape', 'append_batch_size', 'dtype', 'lod_level', 'type', 'stop_gradient'], varargs=None, keywords=None, defaults=(True, 'float32', 0, VarType.LOD_TENSOR, True)), ('document', '9d7806e31bdf727c1a23b8782a09b545')) -paddle.fluid.layers.read_file (ArgSpec(args=['reader'], varargs=None, keywords=None, defaults=None), ('document', '88367daf9a30c9ab83adc5d7221e23ef')) +paddle.fluid.layers.read_file (ArgSpec(args=['reader'], varargs=None, keywords=None, defaults=None), ('document', 'd5b41c7b2df1b064fbd42dcf435268cd')) paddle.fluid.layers.double_buffer (ArgSpec(args=['reader', 'place', 'name'], varargs=None, keywords=None, defaults=(None, None)), ('document', '556fa82daf62cbb0fb393f4125daba77')) paddle.fluid.layers.py_reader (ArgSpec(args=['capacity', 'shapes', 'dtypes', 'lod_levels', 'name', 'use_double_buffer'], varargs=None, keywords=None, defaults=(None, None, True)), ('document', 'd78a1c7344955c5caed8dc13adb7beb6')) paddle.fluid.layers.create_py_reader_by_data (ArgSpec(args=['capacity', 'feed_list', 'name', 'use_double_buffer'], varargs=None, keywords=None, defaults=(None, True)), ('document', '2edf37d57862b24a7a26aa19a3573f73')) @@ -380,8 +380,8 @@ paddle.fluid.layers.StaticRNN.step_input (ArgSpec(args=['self', 'x'], varargs=No paddle.fluid.layers.StaticRNN.step_output (ArgSpec(args=['self', 'o'], varargs=None, keywords=None, defaults=None), ('document', '10a543d40e14408765c5294636646a6c')) paddle.fluid.layers.StaticRNN.update_memory (ArgSpec(args=['self', 'mem', 'var'], varargs=None, keywords=None, defaults=None), ('document', '2021b2399d9a2265e2c254973ed151cd')) paddle.fluid.layers.reorder_lod_tensor_by_rank (ArgSpec(args=['x', 'rank_table'], varargs=None, keywords=None, defaults=None), ('document', 'db67cfcdd20ff6380d125a7553d62121')) -paddle.fluid.layers.Print (ArgSpec(args=['input', 'first_n', 'message', 'summarize', 'print_tensor_name', 'print_tensor_type', 'print_tensor_shape', 'print_tensor_lod', 'print_phase'], varargs=None, keywords=None, defaults=(-1, None, 20, True, True, True, True, 'both')), ('document', '3130bed32922b9fd84ce2dea6250f635')) -paddle.fluid.layers.is_empty (ArgSpec(args=['x', 'cond'], varargs=None, keywords=None, defaults=(None,)), ('document', '3011dc695f490afdf504dc24f628319a')) +paddle.fluid.layers.Print (ArgSpec(args=['input', 'first_n', 'message', 'summarize', 'print_tensor_name', 'print_tensor_type', 'print_tensor_shape', 'print_tensor_lod', 'print_phase'], varargs=None, keywords=None, defaults=(-1, None, 20, True, True, True, True, 'both')), ('document', 'e57b87b4d1f9d4a6c7a3f4e6942dea10')) +paddle.fluid.layers.is_empty (ArgSpec(args=['x', 'cond'], varargs=None, keywords=None, defaults=(None,)), ('document', 'a79576af16e8ce1c6ac61b902b04f10a')) paddle.fluid.layers.sigmoid (ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '7bd26680989f33301a4a68000d5af4b0')) paddle.fluid.layers.logsigmoid (ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '047c2af83166a69728be73fc44e9ad9f')) paddle.fluid.layers.exp (ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', 'f6b0cc458acf7ad822a0c26e72fc22a1')) diff --git a/python/paddle/fluid/layers/control_flow.py b/python/paddle/fluid/layers/control_flow.py index 472c143e1ee..466ae0e8dba 100755 --- a/python/paddle/fluid/layers/control_flow.py +++ b/python/paddle/fluid/layers/control_flow.py @@ -154,17 +154,18 @@ def Print(input, Args: input (Variable): A Tensor to print. - summarize (int): Print this number of elements in the tensor, will print - all if left is negative. + summarize (int): Number of elements in the tensor to be print. If it's + vaule is -1, then all elements in the tensor will be print. message (str): A string message to print as a prefix. first_n (int): Only log `first_n` number of times. - print_tensor_name (bool): Print the tensor name. - print_tensor_type (bool): Print the tensor type. - print_tensor_shape (bool): Print the tensor shape. - print_tensor_lod (bool): Print the tensor lod. + print_tensor_name (bool, optional): Print the tensor name. Default: True. + print_tensor_type (bool, optional): Print the tensor type. Defaultt: True. + print_tensor_shape (bool, optional): Print the tensor shape. Default: True. + print_tensor_lod (bool, optional): Print the tensor lod. Default: True. print_phase (str): Which phase to displace, including 'forward', - 'backward' and 'both'. If set to 'backward' or 'both', will - print the gradients of input tensor. + 'backward' and 'both'. Default: 'both'. If set to 'backward', will + only print the gradients of input tensor; If set to 'both', will + both print the input tensor itself and the gradients of input tensor. Returns: Variable: Output tensor. @@ -189,16 +190,12 @@ def Print(input, Output at runtime: .. code-block:: bash - 1564546375 The content of input layer: The place is:CPUPlace + The content of input layer: The place is:CPUPlace Tensor[fill_constant_0.tmp_0] shape: [10,2,] dtype: x data: 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, - # The information of dtype at runtime may vary in different environments. - # Eg: - # If the dtype='int64' of Tensor y, the corresponding c++ type is int64_t. - # The dtype of output is "x" ("x" is typeid(int64_t).name()) with MacOS and gcc4.8.2 ''' helper = LayerHelper('print' + "_" + input.name, **locals()) output = helper.create_variable_for_type_inference(input.dtype) @@ -2710,8 +2707,8 @@ def is_empty(x, cond=None): Args: x (Variable): The Variable to be tested. - cond (Variable|None): Output parameter. Returns the test result - of given 'x'. Default: None + cond (Variable, optional): Output parameter. Default: None. If this parameter is given, it + saves the test result of given 'x'. Returns: Variable: A bool scalar. True if 'x' is an empty Variable. diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index b4988a64e2d..181e8792198 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -825,14 +825,14 @@ def read_file(reader): A reader is also a Variable. It can be a raw reader generated by `fluid.layers.open_files()` or a decorated one generated by - `fluid.layers.double_buffer()` and so on. + `fluid.layers.double_buffer()` . Args: reader(Variable): The reader to execute. Returns: - Tuple[Variable]: Data read via the given reader. + Tuple[Variable]: Data read from the given reader. Examples: .. code-block:: python -- GitLab