Skip to content

Commit 3d1afe2

Browse files
authored
Merge pull request #11661 from luotao1/for_test
add example of clone(for_test)
2 parents d55cfc6 + d3dd034 commit 3d1afe2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/paddle/fluid/framework.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,11 @@ def clone(self, for_test=False):
13871387
* Set for_test to True when we want to clone the program for testing.
13881388
13891389
Notes: This API DOES NOT prune any operator. Use
1390-
:code:`clone(for_test=True)` before backward and optimization please.
1390+
:code:`clone(for_test=True)` before backward and optimization please. e.g.
1391+
1392+
>>> test_program = fluid.default_main_program().clone(for_test=True)
1393+
>>> optimizer = fluid.optimizer.Momentum(learning_rate=0.01, momentum=0.9)
1394+
>>> optimizer.minimize()
13911395
13921396
Args:
13931397
for_test(bool): True if change the :code:`is_test` attribute of

0 commit comments

Comments
 (0)