提交 7e560558 编写于 作者: Q Qiyang Min 提交者: Jiabin Yang

Imperative fix bugs (cherry pick to 1.4) (#16680)

* Fix imperative bugs

test=release/1.4

* Polish code

test=release/1.4
上级 29f34416
...@@ -16,6 +16,7 @@ from __future__ import print_function ...@@ -16,6 +16,7 @@ from __future__ import print_function
import unittest import unittest
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid import core
from paddle.fluid.dygraph.nn import Embedding from paddle.fluid.dygraph.nn import Embedding
import paddle.fluid.framework as framework import paddle.fluid.framework as framework
from paddle.fluid.optimizer import SGDOptimizer from paddle.fluid.optimizer import SGDOptimizer
...@@ -278,7 +279,8 @@ class TestDygraphPtbRnn(unittest.TestCase): ...@@ -278,7 +279,8 @@ class TestDygraphPtbRnn(unittest.TestCase):
num_steps=num_steps, num_steps=num_steps,
init_scale=init_scale) init_scale=init_scale)
exe = fluid.Executor(fluid.CPUPlace()) exe = fluid.Executor(fluid.CPUPlace(
) if not core.is_compiled_with_cuda() else fluid.CUDAPlace(0))
sgd = SGDOptimizer(learning_rate=1e-3) sgd = SGDOptimizer(learning_rate=1e-3)
x = fluid.layers.data( x = fluid.layers.data(
name="x", shape=[-1, num_steps, 1], dtype='int64') name="x", shape=[-1, num_steps, 1], dtype='int64')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册