Custom loss function in Keras, how to deal with placeholders
I am trying to generate a custom loss function in TF/Keras,the loss function works if it is run in a session and passed constants, however, it stops working when compiled into a Keras. The cost function (thanks to Lior for converting it to TF) def ginicTF(actual,pred): n = int(actual.get_shape()[-1]) inds = K.reverse(tf.nn.top_k(pred,n)[1],axes=[0]) a_s = K.gather(actual,inds) a_c = K.cumsum(a_s) giniSum = K.sum(a_c)/K.sum(a_s) - (n+1)/2.0 return giniSum / n def gini_normalizedTF(a,p): return -ginicTF(a, p) / ginicTF(a, a) #Test the cost function sess = tf.InteractiveSession() p = [0.9, 0.3, 0