以下代码 unique_name 的行为是否符合预期?
Created by: keithyin
from paddle import fluid
import paddle
with fluid.unique_name.guard("first_"):
with fluid.unique_name.guard("ad_tower_"):
x = fluid.layers.data(name="x", shape=[1])
h = fluid.layers.fc(x, size=10)
h2 = fluid.layers.fc(h, size=10)
for param in fluid.default_main_program().global_block().all_parameters():
print(param.name)
print(x.name)
print(h.name)
print(h2.name)
输出: (这里名字不应该是 first_ad_tower_..吗? 下面的输出有点迷惑) ad_tower_ad_tower_fc_0.w_0 ad_tower_ad_tower_fc_0.b_0 first_first_fc_0.w_0 first_first_fc_0.b_0 x ad_tower_ad_tower_fc_0.tmp_1 first_first_fc_0.tmp_1