I have a Keras model that has inputs x_1,...,x_n and d-dimensional outputs f(x_1),...,f(x_n). I'm working on a regression problem with d-dimensional targets y_1,...,y_n.
I would like to minimize the loss-function:
For a fixed meta-parameter a between 0 and 1, return the a^th (empirical) quantile of |f(x_i)-y_i|^2
.
Here is what I have coded so far:
def keras_custom_loss(y_true,y_predicted):
SEs = K.square(y_true-y_predicted)
out_custom = tfp.stats.percentile(SEs, 50.0, interpolation='midpoint')
return out_custom
One issue is that I'd like to avoid using tensorflow_probability and I would like the entire implementation done on Keras.
However, I can't figure out how.