网络权值共享
Created by: yanyq1990
- 版本、环境信息: 1)PaddlePaddle版本:1.5.2.post107 2)CPU/GPU:Driver API Version: 10.1, Runtime API Version: 10.0,cuDNN Version: 7.6. 3)系统环境:ubuntu16.04 4)Python版本号 2.7.12
我采用fluid.unique_name.guard来设置网络变量的名称,并用visualdl显示模型结构:
- 当左右设置不同名称时,代码如下:
with fluid.unique_name.guard('stem-l/'):
conv1a, conv2a, conv_temp4a, up_1a2a = self.stem_block(view_l)
with fluid.unique_name.guard('stem-r/'):
conv1b, conv2b, conv_temp4b, up_1b2b = self.stem_block(view_r)
conc = fluid.layers.concat([up_1a2a, up_1b2b], axis=1)
x = conv2d(conc, num_filters=1, filter_size=3, stride=1, padding=1)
return x
- 当左右设置一样的名称时,代码如下:
with fluid.unique_name.guard('stem/'):
conv1a, conv2a, conv_temp4a, up_1a2a = self.stem_block(view_l)
with fluid.unique_name.guard('stem/'):
conv1b, conv2b, conv_temp4b, up_1b2b = self.stem_block(view_r)
conc = fluid.layers.concat([up_1a2a, up_1b2b], axis=1)
x = conv2d(conc, num_filters=1, filter_size=3, stride=1, padding=1)
return x
两种写法打印出conc的shape都是一样的,要实现共享,fluid.unique_name.guard的用法是否正确?这个问题是paddle的bug还是我的用法不对?