diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 75695fd0f1923e95badd6614dc317167ae1f3fe1..f9dfeb4d2eccfc612895bc52b46b09dcc6095004 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', 'b8e1596c2d42738d0a7c0197912ae5aa')) 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', '5152a3ed0544d4d9600fb53a73f15c38')) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index f49e9005f28930fba6a1ed2a3fce1907275d2a0a..d61f9d9ad0d699f29c01e2e75bb37b3d7bd3889a 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: