【问题标题】:Can the bias of a dense layer be set to zero in Tensorflow?Tensorflow中密集层的偏差可以设置为零吗?
【发布时间】:2019-10-31 13:24:39
【问题描述】:

我正在尝试实现一个神经网络,其中我只需要输入与内核相乘。 Tensorflow 中的密集层还增加了我试图将其设置为零的偏差。从文档中可以使用的唯一变量是bias_regularizer。所以我尝试了以下操作:

def make_zero(_):
    return np.zeros(21,)

out1 = tf.layers.dense(inputs=codeword, units=21, activation=None, bias_regularizer=make_zero)

但我仍然看到偏差值不为零。有没有其他方法可以做到这一点?

【问题讨论】:

    标签: python tensorflow machine-learning


    【解决方案1】:

    查看tf.layers.dense 的文档,您可以使用选项use_bias=False 完全消除偏差:

    out1 = tf.layers.dense(inputs=codeword, units=21, activation=None, use_bias=False)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-04
      • 2020-11-21
      • 1970-01-01
      • 2018-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多