Code: Select all
def p_autoencoder_loss(yTrue,yPred):
def loss(yTrue, y_Pred):
return K.mean(K.square(yTrue - yPred), axis=-1)
def a(image):
return K.mean(K.sin(image))
def b(image):
return K.sqrt(K.cos(image))
a_pred = a(yPred)
a_true = a(yTrue)
b_pred = b(yPred)
b_true = b(yTrue)
empirical_loss = (loss(yTrue, yPred))
a_loss = K.mean(K.square(a_true - a_pred))
b_loss = K.mean(K.square(b_true - b_pred))
final_loss = K.mean(empirical_loss + a_loss + b_loss)
return final_loss
Ich möchte hier im Wesentlichen die zweite Option Tensorflow ausführen: Mehrere Verlustfunktionen vs. mehrere Trainingsoperationen, aber in Keras-Form. Ich möchte auch, dass die Verlustfunktionen unabhängig voneinander sind. Gibt es eine einfache Möglichkeit, dies zu tun?