-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何打印Variable的内容 #28139
Comments
直接使用print(var_list[i])尝试下。 |
print(var_list[i])与print(numpy.array(var_list[i]))的结果是一样的 |
试一下Print这个op。
|
您好,这样好像也不行,会报错说网络的输入为空。按照 https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-beta/api/paddle/fluid/executor/Executor_cn.html#run 里面的说法,"执行器会执行Program或CompiledProgram中的所有算子",所以没有输入不行。您给出的例子能跑通,是因为您的main_program里没有额外的输入需要feed吧? |
尝试下:fluid.global_scope().find_var("weight_name").get_tensor() |
多谢gaowei,问题解决了。 ps: |
静态图训练完成后,我想打印所有参数的data值。于是调用 var_list = fluid.io.get_program_persistable_vars(default_main_program) 获取需要打印的var列表,那接下来怎么打印var内容呢?
如果用 print(numpy.array(var_list[i])) 那么只能得到类似如下内容:
name: "emb_21"
type {
type: LOD_TENSOR
lod_tensor {
tensor {
data_type: FP32
dims: 100
dims: 17
}
}
}
persistable: true
这看起来只是 var.to_string 里的内容,而我要的是 100*17个 FP32的值啊。求指导
The text was updated successfully, but these errors were encountered: