未验证 提交 15453d05 编写于 作者: J Jiabin Yang 提交者: GitHub

test=develop, fix AdgradOptimizer example code (#17401)

上级 3a9ae28d
...@@ -1006,8 +1006,22 @@ class AdagradOptimizer(Optimizer): ...@@ -1006,8 +1006,22 @@ class AdagradOptimizer(Optimizer):
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid
import numpy as np
np_inp = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32)
inp = fluid.layers.data(
name="inp", shape=[2, 2], append_batch_size=False)
out = fluid.layers.fc(inp, size=3)
out = fluid.layers.reduce_sum(out)
optimizer = fluid.optimizer.Adagrad(learning_rate=0.2) optimizer = fluid.optimizer.Adagrad(learning_rate=0.2)
optimizer.minimize(cost) optimizer.minimize(out)
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())
exe.run(
feed={"inp": np_inp},
fetch_list=[out.name])
""" """
_moment_acc_str = "moment" _moment_acc_str = "moment"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册