Closed seanxh closed 5 years ago
import paddle import paddle.fluid as fluid import paddle.fluid.core as core import paddle.fluid.framework as framework from paddle.fluid.executor import Executor shape = [1] gate_size = 10 data = fluid.layers.data(name='data', shape=shape, dtype='float32') input_forward_proj = fluid.layers.fc(name='fc_0',input=data, size=gate_size * 4, act=None, bias_attr=False) forward, state = fluid.layers.dynamic_lstm( name='blstm_0', input=input_forward_proj, size=gate_size * 4,use_peepholes=False) place = fluid.CPUPlace() exe = fluid.Executor(place) exe.run(fluid.default_startup_program()) scope = fluid.global_scope() print scope.find_var('fc_0.w_0').get_tensor()
请问,我如何知道结构里其它块的名字??类似 fc_0.w_0这种? 同时,我要怎么取得这些参数的值呢??
可以打印default_main_program.里面有全部layer的参数。
got。
print fluid.default_startup_program() print np.array(fluid.global_scope().find_var('fc_0.w_0').get_tensor())
即可
请问,我如何知道结构里其它块的名字??类似 fc_0.w_0这种? 同时,我要怎么取得这些参数的值呢??