# How to use a loss functions closed-form gradient even when it does not have a closed-form itself

I have a loss function without a closed analytic form that I want to implement in tensorflow that has a nice clean gradient (i.e. i have some nice gradient function $$f(x)$$ that i want to use for backprop but $$\int_x f(x) \ dx$$ is with no closed form)

Ofcourse i wouldnt be able to evaluate the loss, but i want to use $$f(x)$$ in the optimization process. How could this be accomplished?

• @Brian why? I know its gradient and i don't care about actually evaluating the loss, i just want to use that gradient during optimization Aug 23 '19 at 13:48

TensorFlow allows for custom gradient functions with tf.custom_gradient.