Skip to content

Commit ddc7f39

Browse files
authored
fix sample code error of fluid.dygraph.NaturalExpDecay,test=release/1.8 (#25093)
fix sample code error of fluid.dygraph.NaturalExpDecay
1 parent 12f6440 commit ddc7f39

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

python/paddle/fluid/dygraph/learning_rate_scheduler.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,18 @@ class NaturalExpDecay(LearningRateDecay):
171171
Examples:
172172
.. code-block:: python
173173
174-
import paddle.fluid as fluid
175-
base_lr = 0.1
176-
with fluid.dygraph.guard():
177-
sgd_optimizer = fluid.optimizer.SGD(
178-
learning_rate=fluid.dygraph.NaturalExpDecay(
179-
learning_rate=base_lr,
180-
decay_steps=10000,
181-
decay_rate=0.5,
182-
staircase=True))
174+
import paddle.fluid as fluid
175+
base_lr = 0.1
176+
with fluid.dygraph.guard():
177+
emb = fluid.dygraph.Embedding([10, 10])
178+
sgd_optimizer = fluid.optimizer.SGD(
179+
learning_rate=fluid.dygraph.NaturalExpDecay(
180+
learning_rate=base_lr,
181+
decay_steps=10000,
182+
decay_rate=0.5,
183+
staircase=True),
184+
parameter_list=emb.parameters())
185+
183186
184187
"""
185188

0 commit comments

Comments
 (0)