From e3578ab14c59fa4d8188e3fe95ba220f2b17faa3 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Mon, 18 Jun 2018 09:49:02 +0800 Subject: [PATCH] add doc for init_on_cpu --- python/paddle/fluid/initializer.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/initializer.py b/python/paddle/fluid/initializer.py index caa687a0401..373e9c060de 100644 --- a/python/paddle/fluid/initializer.py +++ b/python/paddle/fluid/initializer.py @@ -29,17 +29,29 @@ _force_init_on_cpu_ = False def force_init_on_cpu(): + """ + The flag of whether force to init variables on CPU. + + Examples: + .. code-block:: python + + if force_init_on_cpu(): + pass + + """ return _force_init_on_cpu_ @contextlib.contextmanager def init_on_cpu(): """ - Switch program with `with` statement + Force the variable to be inited on CPU. Examples: - >>> with init_on_cpu(): - >>> step = layers.create_global_var() + .. code-block:: python + + with init_on_cpu(): + step = layers.create_global_var() """ global _force_init_on_cpu_ -- GitLab