fluid版本如何做计算并打印出来?
Created by: yeyupiaoling
以下是我做写的一个加法计算,
# coding=utf-8
import paddle.fluid as fluid
# 创建两常量
a = fluid.layers.fill_constant(shape=[2, 3], dtype="float32", value=1.0)
b = fluid.layers.fill_constant(shape=[2, 3], dtype="float32", value=1.0)
# 加法计算
c = fluid.layers.sum(a, b)
# 转换为打印信息
c_ = fluid.layers.Print(c)
print(c_)
最后输出的以下张量的信息,但我需要的是它的值
name: "print_0.tmp_0"
type {
type: LOD_TENSOR
lod_tensor {
tensor {
data_type: FP32
dims: 2
dims: 3
}
lod_level: 0
}
}
persistable: false