fc layer设置bias_attr=None后仍包含了bias项
Created by: mapingshuo
复现代码:
import paddle
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[5, 4])
fc = fluid.layers.fc(input=x, size=7, bias_attr=None)
loss = fluid.layers.mean(fc)
sgd = fluid.optimizer.SGD(learning_rate = 0.01)
sgd.minimize(loss)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
fluid.io.save_params(exe,
"demo_model_dir")
with open("main_program", "w") as f:
f.write(str(fluid.default_main_program()))
而文档中说:“如果 bias_attr 非空,则会创建一个偏置变量(bias variable),并把它累加到输出结果中。”