# tf.contrib.summary.scalar

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/ops/summary_ops_v2.py#L757-L786) |

Writes a scalar summary if possible.

    tf.contrib.summary.scalar(
        name, tensor, family=None, step=None
    )

Unlike [`tf.contrib.summary.generic`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/summary/generic) this op may change the dtype
depending on the writer, for both practical and efficiency concerns.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `name` | An arbitrary name for this summary. |
| `tensor` | A [`tf.Tensor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Tensor) Must be one of the following types: `float32`, `float64`, `int32`, `int64`, `uint8`, `int16`, `int8`, `uint16`, `half`, `uint32`, `uint64`. |
| `family` | Optional, the summary's family. |
| `step` | The `int64` monotonic step variable, which defaults to [`tf.compat.v1.train.get_global_step`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/get_global_step). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The created [`tf.Operation`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Operation) or a [`tf.no_op`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/no_op) if summary writing has not been enabled for this context. ||

<br />