我有一个名为e的常规keras模型,我想在我的自定义丢失函数中比较它对y_pred和y_true的输出。from keras import backend as K return K.mean(K.square(e.predict(y_pred)-e.predict(y_true)), axis=-1)
我得到了错误:AttributeError: 'Tenso
我正在尝试使用TensorFlow 2.0为Keras模型编写一个自定义损失函数。我按照类似答案中的说明将输入层放入损失函数中,如下所示 这里 Keras custom loss function: Accessing current input pattern 还有这里 https但我也想将第二个模型的输出添加到损失函数中。一开始,TensorFlow会给出一个类似ValueEr
我正在使用Tensorflow 2.4,Keras 2.4.0版本训练VGG-16模型,以完成多类分类任务。y-true标签是单热编码的。我分别使用几个自定义损失函数来训练模型。首先,我使用了一个自定义的cauchy-schwarz散度损失函数,如下所示: from math import sqrtfrom scipy.stats imp