sparse_softmax_cross_entropy_with_logits 和 softmax_cross_entropy_with_logits 的区别

What’s the difference between sparse_softmax_cross_entropy_with_logits and softmax_cross_entropy_with_logits?

https://stackoverflow.com/questions/37312421/whats-the-difference-between-sparse-softmax-cross-entropy-with-logits-and-softm

The difference is simple:

  • For sparse_softmax_cross_entropy_with_logits, labels must have the shape [batch_size] and the dtype int32 or int64. Each label is an int in range [0, num_classes-1].
    For softmax_cross_entropy_with_logits, labels must have the shape [batch_size, num_classes] and dtype float32 or float64.
  • Labels used in softmax_cross_entropy_with_logits are the one hot version of labels used in sparse_softmax_cross_entropy_with_logits.
  • Another tiny difference is that with sparse_softmax_cross_entropy_with_logits, you can give -1 as a label to have loss 0 on this label.

sparse_softmax_cross_entropy_with_logits的label必须有的shape是[batch_size],dtype是int32或者 int64。每个label是一个int 范围是[0, num_classes-1]
softmax_cross_entropy_with_logits中的label是one-hot 版本的对应到sparse_ 的值。
另一个小的区别是sparse_softmax_cross_entropy_with_logits 可以使用小于0的值作为label.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值