我的自定义成本函数tensorflow2错误

时间:2019-09-02 23:33:06

标签: tensorflow2.0

    def costf(y_pred,y_true):

      d = y_pred - y_true

      result = tf.cond( d < 0, lambda: 1, lambda: 0)

      if(y_pred < y_true ):
         error= tf.math.exp(-d/13)-1 
      else :
         error= tf.math.exp(d/10)-1 

      return error

ValueError:形状必须为0级,但输入形状为[?,?],[?,?]的'loss_26 / dense_26_loss / cond / Switch'(op:'Switch')的等级为2。

0 个答案:

没有答案