From ffa7ff9c023d48fa87cb4637b4d9594de3d04709 Mon Sep 17 00:00:00 2001 From: Roc <30228238+sljlp@users.noreply.github.com> Date: Fri, 28 Jan 2022 16:38:23 +0800 Subject: [PATCH] fix optimizer docs (#39297) --- python/paddle/optimizer/optimizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/paddle/optimizer/optimizer.py b/python/paddle/optimizer/optimizer.py index 989da2db71..47dc02705f 100644 --- a/python/paddle/optimizer/optimizer.py +++ b/python/paddle/optimizer/optimizer.py @@ -91,7 +91,7 @@ class Optimizer(object): loss = paddle.mean(out) adam = paddle.optimizer.Adam(learning_rate=0.1, parameters=linear.parameters()) - out.backward() + loss.backward() adam.step() adam.clear_grad() @@ -114,7 +114,7 @@ class Optimizer(object): 'learning_rate': 0.1 }], weight_decay=0.01) - out.backward() + loss.backward() sgd.step() sgd.clear_grad() @@ -1153,7 +1153,7 @@ class Optimizer(object): adam = paddle.optimizer.Adam(learning_rate=0.1, parameters=linear.parameters(), weight_decay=0.01) - out.backward() + loss.backward() adam.minimize(loss) adam.clear_grad() -- GitLab