From 57a9c2724885b8a996a6930f43a644db8138e753 Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Fri, 16 Oct 2020 11:55:02 +0800 Subject: [PATCH] change paddle.fluid.data to paddle.static.data in sample code (#27992) --- python/paddle/fluid/framework.py | 10 +++++----- python/paddle/nn/functional/input.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index d31b434103..aaceb22b98 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -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') diff --git a/python/paddle/nn/functional/input.py b/python/paddle/nn/functional/input.py index b22a3bd1be..2e4bbd99a7 100644 --- a/python/paddle/nn/functional/input.py +++ b/python/paddle/nn/functional/input.py @@ -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, -- GitLab