Paddle
Paddle copied to clipboard
如何禁用掉fc层的bias参数?
根据文档,fc函数的bias_attr的参数设置为None时,不会生成bias参数,但实际测试发现生成了bias参数变量,请问这个正常吗?
def testfc():
place = fluid.CPUPlace()
exe = fluid.Executor(place)
x = fluid.layers.data(name='x', shape=[128], dtype='float32')
fcout = fluid.layers.fc(
name = 'testfc',
input=x,
size=2,
bias_attr=None
)
exe.run(fluid.default_startup_program())
for name,var in fluid.default_main_program().global_block().vars.iteritems():
if var.persistable:
print name
#output
#testfc.w_0
#testfc.b_0
抱歉,这么久没人回复。需要设置为False:
bias_attr=False
另外,发现文档bug:
http://www.paddlepaddle.org/docs/0.14.0/api/fluid/en/layers.html#fc
稍后提PR修复下。