简体   繁体   中英

Weighted cross-entropy tensorflow

I couldn't find a tensorflow built-in that allows you to pass in labels which don't sum to 1, so tried writing my own: (Input is [batch_size,labels])

tf.reduce_mean(tf.reduce_sum(y_true,axis=1) * tf.reduce_logsumexp(y_pred_logits,axis=1)
 - tf.reduce_sum(y_true * y_pred_logits,axis=1))

However it doesn't seem to be working (loss is diverging). Did I do something wrong?

我认为这是正确的,但我将 Adam 优化器的“epsilon”设置得太低了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM