Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

如何禁用掉fc层的bias参数?

Open lgone2000 opened this issue 8 years ago • 1 comments

根据文档,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    

lgone2000 avatar Jun 18 '18 10:06 lgone2000

抱歉,这么久没人回复。需要设置为False:

bias_attr=False

另外,发现文档bug:

http://www.paddlepaddle.org/docs/0.14.0/api/fluid/en/layers.html#fc

稍后提PR修复下。

qingqing01 avatar Jul 06 '18 05:07 qingqing01