tf.nn.softmax_cross_entropy_with_logits

来源:互联网 发布:unity3d怎么导入场景 编辑:程序博客网 时间:2024/05/18 15:22
softmax_cross_entropy_with_logits(
    _sentinel=None,
    labels=None,
    logits=None,
    dim=-1,
    name=None
)


Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.

也就说这个方法只能用于测量离散分类任务中的概率误差,其中类是相互排斥的。 例如,每个CIFAR-10图像都有且仅有一个标签:图像可以是狗或卡车,但不能同时包含卡车和狗


举例:

 cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits = py_X, labels = input_Y))

logits是神经网络最后一层的输出,对这一层(logits=py_X)计算softmax,得到输出属于每一类的概率。在根据前面计算出类别概率和实际的类(input_Y)计算出交叉熵。

阅读全文
0 0