softmax_cross_entropy_with_logits(
_sentinel=None,
labels=None,
logits=None,
dim=-1,
name=None
)
_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)计算出交叉熵。