I am using CNN to solve a regression problem in a supervised manner. i have input data(X_train) and the target data(y_train). I allow the network to train and during training process in each batch of the corresponding epoch I extracted the predicted data using callbacks. And the extracted predicted data is used to recreate the input data through a numerical simulation and it gives results interms of numpy array. Now I want to compute the loss between predicted data(y_predict) and target(y_true) data and the loss between recreated input data(X_trainâ€™) and original input data(X_train) and finally i want to add these two loss functions. Important thing is that simultaneously network is doing two things.

I looked into this Keras custom loss function: Accessing current input pattern but not getting idea on how to proceed.

Hope experts may provide the solution with small example. Thanks in advance.