How to use part of inputs for training but rest for loss function in Keras

人盡茶涼 提交于 2021-02-10 06:28:19

问题


I am new to Keras and trying to implement a neural network machine learning model. The input tensor looks like (X1, X2) and outputs (Y). Note X1 and X2 are correlated. In the model, only X1 will be used for training, but both X1 and X2 will be passed to the loss function that is a function of X1, X2, y_pred and y_true. Below is a pseudocode for loss function.

def customLossFunctionWrapper(input_tensor):
    def LossFunction(y_pred, y_true):
        loss_value = f(X1, X2, y_pred, y_true)
        return loss_value.

My question is different from Keras custom loss function: Accessing current input pattern. I need to mask part of input_tensor in training model but use the masked part in the loss function. Can anyone offer me some idea? Thank you in advance.

来源:https://stackoverflow.com/questions/51576796/how-to-use-part-of-inputs-for-training-but-rest-for-loss-function-in-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!