import tensorflow as tf
labels = [[0.2,0.3,0.5],
[0.1,0.6,0.3]]
logits = [[2,0.5,1],
[0.1,1,3]]
weight=[[1],
[2]]
result1 = tf.nn.softmax_cross_entropy_with_logits(labels=labels, logits=logits)
logits_scaled = tf.nn.softmax(logits)
result2 = -tf.reduce_sum(labels*tf.log(logits_scaled),1)
result3 = tf.nn.softmax_cross_entropy_with_logits(labels=labels, logits=logits_scaled)
with tf.Session() as sess:
print(sess.run(result1))
print(sess.run(weight*result1))
print(sess.run(result2))
print(sess.run(result3))
[1.4143689 1.6642545]
[[1.4143689 1.6642545]
[2.8287377 3.328509 ]]
[1.4143689 1.6642545]
[1.1718578 1.1757141]