# Optimization of a custom loss function

I want to implement a deep learning model in Keras, but I want to use my own loss function, i.e. custom loss. If I implement some loss function and use Keras Functional API for the model, do I need to change the way the optimizer works, because the optimizer will minimize my loss function? If I need to do that, what is the way to do that?

You don't need to change the way optimizer works. You just need to define your loss function in some standard way.

Checkout the answer in this post to have an idea on an example of customizing loss function in Keras.

https://stackoverflow.com/questions/45961428/make-a-custom-loss-function-in-keras

Write your custom loss function in Tensorflow or Keras backend, keeping in mind that the function takes two inputs of y_pred and y_true and then feed the function into the model.compile command in the loss section. If your function was:

def my_loss (y_true,y_pred):
...


then in the model.compile you would have loss=[my_loss].