Hello. I want to create a neural network that has a loss function coming from two sources: the output of the neural network, as well as a function applied to this output. Basically, this function takes in values that are coming from the neural network, and produces a set of new values. I want to simultaneously take into account losses coming directly from the output of the neural network AND the output of the function given this prediction, to generate a prediction that gives me the best function output.
For instance:
Loss = MSE(prediction, target) + MSE(function(pred), function(target))
The important thing to note is that this function is coming from an external python library, and it is not something I can recreate in Pytorch. Would this work? What can I do so that it works as a Pytorch function?