【问题标题】:Tensorflow: Manipulate bias during trainingTensorflow:在训练期间操纵偏差
【发布时间】:2019-02-17 00:29:15
【问题描述】:

我训练了一个模型,并希望在训练期间操纵所有偏差项。为此,我使用参数change_bias构建图形

change_bias = tf.placeholder(tf.float32)
b = change_bias * b

为了操纵偏差项,如果我希望减少偏差,我希望能够输入 change_bias=0.1

我的方法不起作用。在训练期间操纵模型偏差的正确方法是什么?

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    因为 b 被定义为变量这是错误的:

    b = change_bias * b
    

    试试这样的:

    import tensorflow as tf
    
    x=tf.placeholder(tf.float32,shape=[-1,26])
    change_bias=tf.placeholder(tf.float32,shape=[])
    b=tf.Variable(tf.zeros([26]),name="bias")
    
    output=x+tf.math.multiply(b,change_bias)
    

    编辑:change_bias 必须是标量

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多