tensorflow带权重的交叉熵简单使用

logits=[[0.2,0.3,0.4,0.1]]
one_hot_labels = tf.one_hot([2],depth=4,dtype=tf.float32)
loss_ = tf.nn.weighted_cross_entropy_with_logits(labels=one_hot_labels, logits=logits, pos_weight=0.1)
with tf.Session() as session:
    print(session.run(tf.reduce_mean(loss_)))

猜你喜欢

转载自blog.csdn.net/u011939633/article/details/103499750