tf.keras.backend.sparse_categorical_crossentropy
Stay organized with collections
Save and categorize content based on your preferences.
Categorical crossentropy with integer targets.
tf.keras.backend.sparse_categorical_crossentropy(
target, output, from_logits=False, axis=-1
)
Arguments |
target
|
An integer tensor.
|
output
|
A tensor resulting from a softmax
(unless from_logits is True, in which
case output is expected to be the logits).
|
from_logits
|
Boolean, whether output is the
result of a softmax, or is a tensor of logits.
|
axis
|
Int specifying the channels axis. axis=-1 corresponds to data
format channels_last', and axis=1corresponds to data format channels_first`.
|
Raises |
ValueError
|
if axis is neither -1 nor one of the axes of output .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.keras.backend.sparse_categorical_crossentropy\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 2 version](/api_docs/python/tf/keras/backend/sparse_categorical_crossentropy) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/backend.py#L4376-L4451) |\n\nCategorical crossentropy with integer targets.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.keras.backend.sparse_categorical_crossentropy`](/api_docs/python/tf/keras/backend/sparse_categorical_crossentropy), \\`tf.compat.v2.keras.backend.sparse_categorical_crossentropy\\`\n\n\u003cbr /\u003e\n\n tf.keras.backend.sparse_categorical_crossentropy(\n target, output, from_logits=False, axis=-1\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| `target` | An integer tensor. |\n| `output` | A tensor resulting from a softmax (unless `from_logits` is True, in which case `output` is expected to be the logits). |\n| `from_logits` | Boolean, whether `output` is the result of a softmax, or is a tensor of logits. |\n| `axis` | Int specifying the channels axis. `axis=-1` corresponds to data format `channels_last', and`axis=1`corresponds to data format`channels_first\\`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Output tensor. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|----------------------------------------------------------|\n| `ValueError` | if `axis` is neither -1 nor one of the axes of `output`. |\n\n\u003cbr /\u003e"]]