0
我在張量流中創建SMAPE損失函數,並且在計算減少均值之前,我需要將張量diff的值設置爲0。這裏是我的代碼,但它不工作:在張量流中將值設置爲cero
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必須指定的形狀:張量( 「div_49:0」,D類= FLOAT32)
有人可以幫助我,謝謝?