I am trying to create the following metric for my neural network using keras:
where d=y_{pred}-y_{true}
and both y_{pred} and y_{true} are vectors
With the following code:
import keras.backend as K
def score(y_true, y_pred):
d=(y_pred - y_true)
if d<0:
return K.exp(-d/10)-1
else:
return K.exp(d/13)-1
For the use of compiling my model:
model.compile(loss='mse', optimizer='adam', metrics=[score])
I received the following error code and I have not been able to correct the issue. Any help would be appreciated.
raise TypeError("Using a
tf.Tensor
as a Pythonbool
is not allowed. " "Useif t is not None:
instead ofif t:
to test if a " "tensor is defined, and use TensorFlow ops such as "TypeError: Using a
tf.Tensor
as a Pythonbool
is not allowed. Useif t is not None:
instead ofif t:
to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.