import tensorflow as tf a = tf.losses.categorical_crossentropy([0,1,0,0],[0.25,0.25,0.25,0.25],from_logits=True) # 前一个参数为标记值,后一个参数为预测值,最后一个参数设为True,输出就不用做softmax print('a:',a) b = tf.losses.categorical_crossentropy([0,1,0,0],[0.1,0.1,0.1,0.7]) # 前一个参数为标记值,后一个参数为预测值 print('b:',b) c = tf.losses.categorical_crossentropy([0,1,0,0],[0.1,0.7,0.1,0.1]) # 前一个参数为标记值,后一个参数为预测值 print('c:',c) d = tf.losses.categorical_crossentropy([0,1,0,0],[0,0.7,0,0.3]) # 前一个参数为标记值,后一个参数为预测值 print('d:',d) e = tf.losses.categorical_crossentropy([0,1,0,0],[0.02,0.9,0.03,0.05]) # 前一个参数为标记值,后一个参数为预测值 print('e:',e) f = tf.losses.categorical_crossentropy([1,0],[0.9,0.1]) # 前一个参数为标记值,后一个参数为预测值 print('f:',f)