layers.Print()为何不起作用了
orangezcorange 发布于2020-03-30 21:09 浏览:290 回复:1
0
收藏

fluid.layers.Print()没有打印任何信息

这是官方文档中的实例:

import paddle.fluid as fluid
import paddle
import numpy as np

x = fluid.layers.data(name='x', shape=[1], dtype='float32', lod_level=1)
x = fluid.layers.Print(x, message="The content of input layer:")

y = fluid.layers.data(name='y', shape=[1], dtype='float32', lod_level=2)
out = fluid.layers.sequence_expand(x=x, y=y, ref_level=0)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
x_d = fluid.create_lod_tensor(np.array([[1.1], [2.2],[3.3],[4.4]]).astype('float32'), [[1,3]], place)
y_d = fluid.create_lod_tensor(np.array([[1.1],[1.1],[1.1],[1.1],[1.1],[1.1]]).astype('float32'), [[1,3], [1,2,1,2]], place)
results = exe.run(fluid.default_main_program(),
                  feed={'x':x_d, 'y': y_d },
                  fetch_list=[out],return_numpy=False)

可是我的运行结果没有打印任何信息

收藏
点赞
0
个赞
共1条回复 最后由鹿鼎记肯定回复于2020-04-21 08:17
#2鹿鼎记肯定回复于2020-04-21 08:17:12

应该是jupyter是不是不能捕获C++ std::cout的输出,我已经跟他们反馈了

0
TOP
切换版块