未验证 提交 57a9c272 编写于 作者: C chentianyu03 提交者: GitHub

change paddle.fluid.data to paddle.static.data in sample code (#27992)

上级 d330cf66
......@@ -543,7 +543,7 @@ def name_scope(prefix=None):
import paddle
paddle.enable_static()
with paddle.static.name_scope("s1"):
a = paddle.fluid.data(name='data', shape=[None, 1], dtype='int32')
a = paddle.static.data(name='data', shape=[None, 1], dtype='int32')
b = a + 1
with paddle.static.name_scope("s2"):
c = b * 1
......@@ -5357,8 +5357,8 @@ def default_startup_program():
main_program = paddle.static.Program()
startup_program = paddle.static.Program()
with paddle.static.program_guard(main_program=main_program, startup_program=startup_program):
x = paddle.fluid.data(name="x", shape=[-1, 784], dtype='float32')
y = paddle.fluid.data(name="y", shape=[-1, 1], dtype='int32')
x = paddle.static.data(name="x", shape=[-1, 784], dtype='float32')
y = paddle.static.data(name="y", shape=[-1, 1], dtype='int32')
z = paddle.static.nn.fc(name="fc", x=x, size=10, activation="relu")
print("main program is: {}".format(paddle.static.default_main_program()))
......@@ -5391,8 +5391,8 @@ def default_main_program():
paddle.enable_static()
# Sample Network:
data = paddle.fluid.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
label = paddle.fluid.data(name='label', shape=[None, 1], dtype='int64')
data = paddle.static.data(name='image', shape=[None, 3, 224, 224], dtype='float32')
label = paddle.static.data(name='label', shape=[None, 1], dtype='int64')
conv1 = paddle.static.nn.conv2d(data, 4, 5, 1, act=None)
bn1 = paddle.static.nn.batch_norm(conv1, act='relu')
......
......@@ -74,7 +74,7 @@ def one_hot(x, num_classes, name=None):
import paddle
# Correspond to the first example above, where label.shape is 4 and one_hot_label.shape is [4, 4].
label = paddle.fluid.data(name="label", shape=[4, 1], dtype="int64")
label = paddle.static.data(name="label", shape=[4, 1], dtype="int64")
# label.shape = [4]
# label.data = [1, 1, 3, 0]
one_hot_label = paddle.nn.functional.one_hot(x=label, num_classes=4)
......@@ -183,7 +183,7 @@ def embedding(x, weight, padding_idx=None, sparse=False, name=None):
weight = prog.global_block().create_parameter(
(128, 100), dtype="float32", default_initializer=Constant(1.0))
label = paddle.fluid.data(
label = paddle.static.data(
name="label",
shape=[4],
append_batch_size=False,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册