怎么解决这个新手常见的一个warning
军人的生活就是 发布于2021-01 浏览:144 回复:0
0
收藏
最后编辑于2021-01

新手问题:

代码如下:

import paddle
import paddle.fluid as fluid
import numpy

paddle.enable_static()

a = fluid.data(name="a", shape=[1], dtype='float32')
b = fluid.data(name="b", shape=[1], dtype='float32')

result = fluid.layers.elementwise_add(a, b)

place = paddle.CPUPlace()
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())

x = numpy.array([5]).astype("float32")
y = numpy.array([7]).astype("float32")

outs = exe.run(
    feed={'a': x, 'b': y},
    fetch_list=[result])
print(outs)

然后报Warning:

UserWarning: There are no operators in the program to be executed. If you pass Program manually, please use fluid.program_guard to ensure the current Program is being used.

能解释一下这个warning的含义吗?是什么原因引起的这个warning?要怎么改代码才能消除这个warning呢?能否给个实例呢?

 

收藏
点赞
0
个赞
TOP
切换版块