def weighted_binary_crossentropy(feature_weights):
def loss(y_true, y_pred):
# try:
# x = K.binary_crossentropy(y_pred, y_true)
# # y = tf.Variable(feature_weights.astype('float32'))
# # z = K.dot(x, y)
# y_true = tf.pow(y_true + 1e-5, .75)
# y2 = tf.div(y_true, tf.reshape(K.sum(y_true, 1), [-1, 1]))
# z = K.sum(tf.mul(x, y2), 1)
# except Exception as e:
# print e
# import pdb;pdb.set_trace()
# return z
return K.dot(K.binary_crossentropy(y_pred, y_true), K.variable(feature_weights.astype('float32')))
return loss
评论列表
文章目录