【发布时间】:2021-09-02 02:47:26
【问题描述】:
我是张量流的新手。我正在这样做-
def loss_function(y_pred, y_true):
return -tf.reduce_mean(tf.matmul(y_true, tf.math.log(y_pred)) + tf.matmul(1-y_true, tf.math.log(1-y_pred)))
为此,我收到此错误-
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-28-84f43999b37a> in <module>()
20 with tf.GradientTape() as tape:
21 y_predicted = h(x_train,w)
---> 22 costF = loss_function(y_predicted, y)
23
24 gradients = tape.gradient(costF, w)
5 frames
/usr/local/lib/python3.7/dist-packages/six.py in raise_from(value, from_value)
InvalidArgumentError: cannot compute BatchMatMulV2 as input #1(zero-based) was expected to be a int64 tensor but is a double tensor [Op:BatchMatMulV2]
有人可以帮忙吗?
【问题讨论】:
标签: python tensorflow tensor