【发布时间】:2018-02-13 05:15:36
【问题描述】:
我正在 tensorflow 中创建 SMAPE 损失函数,我需要在计算减少均值之前将张量差异的值设置为 0。这是我的代码,但它不起作用:
function loss(yHat, y):
denominator = (tf.abs(yhat) + np.abs(y))/2.0
diff = tf.div(tf.abs(yhat - y),denominator)
other_variable = tf.get_variable("other_variable",
dtype=tf.float32,
initializer= diff)
comp = tf.equal(denominator, 0)
cond_diff = tf.scatter_update(other_variable, comp, 0)
return tf.reduce_mean(cond_diff)
它给了我这个错误
ValueError:initial_value 必须具有指定的形状:Tensor("div_49:0", dtype=float32)
【问题讨论】:
标签: tensorflow