tf.nn.softmax_cross_entropy_with_logits

tf.nn.softmax_cross_entropy_with_logits(_sentinel=None, labels=None, logits=None, dim=-1, name=None)

Docstring:

Computes softmax cross entropy between logits and labels.

Type: function

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.

softmax搭配使用的交叉熵损失函数,输入不需要额外加一层softmaxsoftmax_cross_entropy_with_logits中会集成有softmax并进行了计算优化;它适用于分类的类别之间是相互排斥的场景,即只有一个标签(不是狗就是猫)。

NOTE: While the classes are mutually exclusive, their probabilities need not be. All that is required is that each row of labels is a valid probability distribution. If they are not, the computation of the gradient will be incorrect.

If using exclusive labels (wherein one and only one class is true at a time), see sparse_softmax_cross_entropy_with_logits.

WARNING: This op expects unscaled logits, since it performs a softmax on logits internally for efficiency. Do not call this op with the output of softmax, as it will produce incorrect results.

logits and labels must have the same shape [batch_size, num_classes] and the same dtype (either float16, float32, or float64).

Note that to avoid confusion, it is required to pass only named arguments to this function.

Args:

_sentinel: Used to prevent positional parameters. Internal, do not use.
labels: Each row labels[i] must be a valid probability distribution.
logits: Unscaled log probabilities.
dim: The class dimension. Defaulted to -1 which is the last dimension.
name: A name for the operation (optional).

Returns:

A 1-D Tensor of length batch_size of the same type as logits with the
softmax cross entropy loss.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 谁注定了他要坐在路边入睡 行人脚下路的命脉在蹦嗒呢 (图片来自朋友圈,朋友拍)
    万象更新_f742阅读 1,445评论 0 0
  • “妈!你先下来!我怎么可能不理解你!我是你的女儿啊!” “理解我,就别再劝我自首!你知道我的选择!” …… 她一...
    浅秋wx阅读 3,304评论 4 6
  • 在专栏的学习中,我们认识到,所谓的聪明就是脑子里有多少清晰、准确、必要的概念,那些清晰、准确、必要的概念之...
    浪哩嘎浪阅读 3,106评论 2 6
  • 产品:苹果相册 图片分享 亮点: - 点击图片分享,分享操作面板从下往上推,自然流畅; - 分享包含三组功能:ai...
    FanFanny阅读 1,594评论 5 0

友情链接更多精彩内容