交叉熵表示两个概率分布之间的距离,公式如下:

交叉熵公式
在人眼里,y2(0.8,0.2)更接近y,机器学习通过公式计算,y2的距离h2也确实更小,证明了这个公式的有效性

示例
在tensorflow中表示:
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y * tf.log(predict),reduction_indices=[1])) # -sum(标准值 * log(预测值))
交叉熵表示两个概率分布之间的距离,公式如下:
在tensorflow中表示:
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y * tf.log(predict),reduction_indices=[1])) # -sum(标准值 * log(预测值))