Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.
See tf.nn.softmax_cross_entropy_with_logits_v2.
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.
If using exclusive labels (wherein one and only
one class is true at a time), see sparse_softmax_cross_entropy_with_logits.
A common use case is to have logits and labels of shape
[batch_size, num_classes], but higher dimensions are supported, with
the dim argument specifying the class dimension.
Backpropagation will happen only into logits. To calculate a cross entropy
loss that allows backpropagation into both logits and labels, see
tf.nn.softmax_cross_entropy_with_logits_v2.
Note that to avoid confusion, it is required to pass only named arguments to
this function.
Args
labels
Each vector along the class dimension should hold a valid
probability distribution e.g. for the case in which labels are of shape
[batch_size, num_classes], each row of labels[i] must be a valid
probability distribution.
logits
Per-label activations, typically a linear output. These activation
energies are interpreted as unnormalized log probabilities.
dim
The class dimension. Defaulted to -1 which is the last dimension.
name
A name for the operation (optional).
axis
Alias for dim.
Returns
A Tensor that contains the softmax cross entropy loss. Its type is the
same as logits and its shape is the same as labels except that it does
not have the last dimension of labels.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.nn.softmax_cross_entropy_with_logits\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/nn_ops.py#L4184-L4247) |\n\nComputes softmax cross entropy between `logits` and `labels`. (deprecated) \n\n tf.compat.v1.nn.softmax_cross_entropy_with_logits(\n labels=None, logits=None, dim=-1, name=None, axis=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating:\n\nFuture major versions of TensorFlow will allow gradients to flow\ninto the labels input on backprop by default.\n\nSee `tf.nn.softmax_cross_entropy_with_logits_v2`.\n\nMeasures the probability error in discrete classification tasks in which the\nclasses are mutually exclusive (each entry is in exactly one class). For\nexample, each CIFAR-10 image is labeled with one and only one label: an image\ncan be a dog or a truck, but not both.\n| **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.\n\nIf using exclusive `labels` (wherein one and only\none class is true at a time), see `sparse_softmax_cross_entropy_with_logits`.\n| **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.\n\nA common use case is to have logits and labels of shape\n`[batch_size, num_classes]`, but higher dimensions are supported, with\nthe `dim` argument specifying the class dimension.\n\nBackpropagation will happen only into `logits`. To calculate a cross entropy\nloss that allows backpropagation into both `logits` and `labels`, see\n`tf.nn.softmax_cross_entropy_with_logits_v2`.\n\n**Note that to avoid confusion, it is required to pass only named arguments to\nthis function.**\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `labels` | Each vector along the class dimension should hold a valid probability distribution e.g. for the case in which labels are of shape `[batch_size, num_classes]`, each row of `labels[i]` must be a valid probability distribution. |\n| `logits` | Per-label activations, typically a linear output. These activation energies are interpreted as unnormalized log probabilities. |\n| `dim` | The class dimension. Defaulted to -1 which is the last dimension. |\n| `name` | A name for the operation (optional). |\n| `axis` | Alias for dim. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` that contains the softmax cross entropy loss. Its type is the same as `logits` and its shape is the same as `labels` except that it does not have the last dimension of `labels`. ||\n\n\u003cbr /\u003e"]]