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)计算出交叉熵。
本文介绍Softmax交叉熵损失函数的应用场景及其在 TensorFlow 中的实现方式。该函数适用于离散分类任务,特别是当每个样本只属于一个类别时。通过实例展示了如何使用此函数来计算神经网络的损失。
426

被折叠的 条评论
为什么被折叠?



