From 408bd8b874cbbfb8cb6123405fe50ed8579e0ec0 Mon Sep 17 00:00:00 2001 From: xujiaqi01 <173596896@qq.com> Date: Thu, 10 Oct 2019 23:01:29 +0800 Subject: [PATCH] fix en doc and test=document_fix (#20441) * fix en doc train_from_dataset and infer_from_datatset --- paddle/fluid/API.spec | 4 +-- python/paddle/fluid/executor.py | 55 +++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 504ba50782b..5a083cb8790 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -30,9 +30,9 @@ paddle.fluid.load_op_library (ArgSpec(args=['lib_filename'], varargs=None, keywo paddle.fluid.Executor ('paddle.fluid.executor.Executor', ('document', '4d963107d87438b5add4a5288855bd04')) paddle.fluid.Executor.__init__ (ArgSpec(args=['self', 'place'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) paddle.fluid.Executor.close (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', '90b3268b71a8aceedd0dc9e311921d15')) -paddle.fluid.Executor.infer_from_dataset (ArgSpec(args=['self', 'program', 'dataset', 'scope', 'thread', 'debug', 'fetch_list', 'fetch_info', 'print_period', 'fetch_handler'], varargs=None, keywords=None, defaults=(None, None, None, 0, False, None, None, 100, None)), ('document', '4ff256774ecaeee01c840a5fb5de8f7a')) +paddle.fluid.Executor.infer_from_dataset (ArgSpec(args=['self', 'program', 'dataset', 'scope', 'thread', 'debug', 'fetch_list', 'fetch_info', 'print_period', 'fetch_handler'], varargs=None, keywords=None, defaults=(None, None, None, 0, False, None, None, 100, None)), ('document', '67de8ce7fbc618da50037d33cf7a7dbc')) paddle.fluid.Executor.run (ArgSpec(args=['self', 'program', 'feed', 'fetch_list', 'feed_var_name', 'fetch_var_name', 'scope', 'return_numpy', 'use_program_cache'], varargs=None, keywords=None, defaults=(None, None, None, 'feed', 'fetch', None, True, False)), ('document', 'de3878f012e60edad05fb24fd88ce910')) -paddle.fluid.Executor.train_from_dataset (ArgSpec(args=['self', 'program', 'dataset', 'scope', 'thread', 'debug', 'fetch_list', 'fetch_info', 'print_period', 'fetch_handler'], varargs=None, keywords=None, defaults=(None, None, None, 0, False, None, None, 100, None)), ('document', '73024c79f46b4f14f1060edeaa4919c8')) +paddle.fluid.Executor.train_from_dataset (ArgSpec(args=['self', 'program', 'dataset', 'scope', 'thread', 'debug', 'fetch_list', 'fetch_info', 'print_period', 'fetch_handler'], varargs=None, keywords=None, defaults=(None, None, None, 0, False, None, None, 100, None)), ('document', 'f35879c6935d87255d4317c7d0d02ab6')) paddle.fluid.global_scope (ArgSpec(args=[], varargs=None, keywords=None, defaults=None), ('document', 'f65788d9ead293ada47551339df12203')) paddle.fluid.scope_guard (ArgSpec(args=['scope'], varargs=None, keywords=None, defaults=None), ('document', '02fcfc1eda07c03a84ed62422366239c')) paddle.fluid.DistributeTranspiler ('paddle.fluid.transpiler.distribute_transpiler.DistributeTranspiler', ('document', 'b2b19821c5dffcd11473d6a4eef089af')) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index d77cfc8dba7..f2d5cc3ffce 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -1048,25 +1048,31 @@ class Executor(object): print_period=100, fetch_handler=None): """ - The document of infer_from_dataset is almost the same as - train_from_dataset, except that in distributed training, - push gradients will be disabled in infer_from_dataset. - infer_from_dataset() can be used for evaluation in multi-thread - very easily. + Infer from a pre-defined Dataset. Dataset is defined in paddle.fluid.dataset. + Given a program, either a program or compiled program, infer_from_dataset will + consume all data samples in dataset. Input scope can be given by users. By default, + scope is global_scope(). The total number of thread run in training is `thread`. + Thread number used in training will be minimum value of threadnum in Dataset and + the value of thread in this interface. Debug can be set so that executor will display + Run-Time for all operators and the throughputs of current infer task. + + The document of infer_from_dataset is almost the same as train_from_dataset, + except that in distributed training, push gradients will be disabled in infer_from_dataset. + infer_from_dataset() can be used for evaluation in multi-threadvery easily. Args: program(Program|CompiledProgram): the program that needs to be run, - if not provided, then default_main_program (not compiled) will be used. + if not provided, then default_main_program (not compiled) will be used. dataset(paddle.fluid.Dataset): dataset created outside this function, - a user should provide a well-defined dataset before calling this function. - Please check the document of Dataset if needed. default is None + a user should provide a well-defined dataset before calling this function. + Please check the document of Dataset if needed. default is None scope(Scope): the scope used to run this program, you can switch it to different scope - for each run. default is global_scope - thread(int): number of thread a user wants to run in this function. The actual number - of thread will be min(Dataset.thread_num, thread) if thread > 0, default is 0 + for each run. default is global_scope + thread(int): number of thread a user wants to run in this function. Default is 0, which + means using thread num of dataset debug(bool): whether a user wants to run infer_from_dataset, default is False - fetch_list(Variable List): fetch variable list, each variable - will be printed during training, default is None + fetch_list(Variable List): fetch variable list, each variable will be printed during + training, default is None fetch_info(String List): print information for each variable, default is None print_period(int): the number of mini-batches for each print, default is 100 fetch_handler(FetchHandler): a user define class for fetch output. @@ -1116,24 +1122,25 @@ class Executor(object): Thread number used in training will be minimum value of threadnum in Dataset and the value of thread in this interface. Debug can be set so that executor will display Run-Time for all operators and the throughputs of current training task. - + Note: train_from_dataset will destroy all resources created within executor for each run. Args: program(Program|CompiledProgram): the program that needs to be run, - if not provided, then default_main_program (not compiled) will be used. + if not provided, then default_main_program (not compiled) will be used. dataset(paddle.fluid.Dataset): dataset created outside this function, - a user should provide a well-defined dataset before calling this function. - Please check the document of Dataset if needed. + a user should provide a well-defined dataset before calling this function. + Please check the document of Dataset if needed. scope(Scope): the scope used to run this program, you can switch it to different scope - for each run. default is global_scope - thread(int): number of thread a user wants to run in this function. The actual number - of thread will be min(Dataset.thread_num, thread) + for each run. default is global_scope + thread(int): number of thread a user wants to run in this function. Default is 0, which + means using thread num of dataset debug(bool): whether a user wants to run train_from_dataset - fetch_list(Variable List): fetch variable list, each variable - will be printed during training - fetch_info(String List): print information for each variable - print_period(int): the number of mini-batches for each print + fetch_list(Variable List): fetch variable list, each variable will be printed + during training + fetch_info(String List): print information for each variable, its length should be equal + to fetch_list + print_period(int): the number of mini-batches for each print, default is 100 fetch_handler(FetchHandler): a user define class for fetch output. Returns: -- GitLab