View source on GitHub |
Computes sparse softmax cross entropy between logits
and labels
.
tf.contrib.nn.deprecated_flipped_sparse_softmax_cross_entropy_with_logits(
logits, labels, name=None
)
This function diffs from tf.nn.sparse_softmax_cross_entropy_with_logits only in the argument order.
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.
A common use case is to have logits of shape [batch_size, num_classes]
and
labels of shape [batch_size]
. But higher dimensions are supported.
Args | |
---|---|
logits
|
Unscaled log probabilities of rank r and shape
[d_0, d_1, ..., d_{r-2}, num_classes] and dtype float32 or float64 .
|
labels
|
Tensor of shape [d_0, d_1, ..., d_{r-2}] and dtype int32 or
int64 . Each entry in labels must be an index in [0, num_classes) .
Other values will raise an exception when this op is run on CPU, and
return NaN for corresponding corresponding loss and gradient rows
on GPU.
|
name
|
A name for the operation (optional). |
Returns | |
---|---|
A Tensor of the same shape as labels and of the same type as logits
with the softmax cross entropy loss.
|
Raises | |
---|---|
ValueError
|
If logits are scalars (need to have rank >= 1) or if the rank of the labels is not equal to the rank of the logits minus one. |