1

I'm trying to build a custom loss function which utilizes the gradient of the outputs predicted by the model (i.e. gradient of y_pred). For example, the loss function may try to minimize the mean squared error between the gradient of the model output (grad(y_pred)) and y_true.

Although many operations like taking the square of y_pred inside the custom loss function is okay, using its gradient within the custom loss function is lnot possible. I understand that this might be because y_pred is simply a reference to a computational graph, and doesn't have any values initially. Can someone please suggest a workaround for this?

  • Possible duplicate of [Make a custom loss function in keras](https://stackoverflow.com/questions/45961428/make-a-custom-loss-function-in-keras) – alift Mar 09 '19 at 06:40
  • It's not a duplicate of the question your link refers to. This is not about how to create a custom loss function, this is about doing a specific operation within it. – Tarak Nath Nandi Mar 09 '19 at 15:37

0 Answers0