tf.summary.text
Stay organized with collections
Save and categorize content based on your preferences.
Write a text summary.
tf.summary.text(
name, data, step=None, description=None
)
See also <a href="../../tf/summary/scalar"><code>tf.summary.scalar</code></a>, <a href="../../tf/summary/SummaryWriter"><code>tf.summary.SummaryWriter</code></a>, <a href="../../tf/summary/image"><code>tf.summary.image</code></a>.
Writes text Tensor values for later visualization and analysis in TensorBoard.
Writes go to the current default summary writer. Like <a href="../../tf/summary/scalar"><code>tf.summary.scalar</code></a>
points, text points are each associated with a `step` and a `name`.
All the points with the same `name` constitute a time series of text values.
For Example:
```python
test_summary_writer = tf.summary.create_file_writer('test/logdir')
with test_summary_writer.as_default():
tf.summary.text('first_text', 'hello world!', step=0)
tf.summary.text('first_text', 'nice to meet you!', step=1)
```
The text summary can also contain Markdown, and TensorBoard will render the text
as such.
```python
with test_summary_writer.as_default():
text_data = '''
| *hello* | *there* |
|---------|---------|
| this | is |
| a | table |
'''
text_data = '
'.join(l.strip() for l in text_data.splitlines())
tf.summary.text('markdown_text', text_data, step=0)
```
Since text is Tensor valued, each text point may be a Tensor of string values.
rank-1 and rank-2 Tensors are rendered as tables in TensorBoard. For higher ranked
Tensors, you'll see just a 2D slice of the data. To avoid this, reshape the Tensor
to at most rank-2 prior to passing it to this function.
Demo notebook at
["Displaying text data in TensorBoard"](https://www.tensorflow.org/tensorboard/text_summaries).
Arguments:
name: A name for this summary. The summary tag used for TensorBoard will
be this name prefixed by any active name scopes.
data: A UTF-8 string Tensor value.
step: Explicit `int64`-castable monotonic step value for this summary. If
omitted, this defaults to <a href="../../tf/summary/experimental/get_step"><code>tf.summary.experimental.get_step()</code></a>, which must
not be None.
description: Optional long-form description for this summary, as a
constant `str`. Markdown is supported. Defaults to empty.
Returns:
True on success, or false if no summary was emitted because no default
summary writer was available.
Raises:
ValueError: if a default writer exists, but no step was provided and
<a href="../../tf/summary/experimental/get_step"><code>tf.summary.experimental.get_step()</code></a> is None.
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. Some content is licensed under the numpy license.
Last updated 2021-05-14 UTC.
[null,null,["Last updated 2021-05-14 UTC."],[],[],null,["# tf.summary.text\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/summary/text) | [View source on GitHub](https://github.com/tensorflow/tensorboard/tree/master/tensorboard/plugins/text/summary_v2.py#L26-L97) |\n\nWrite a text summary. \n\n tf.summary.text(\n name, data, step=None, description=None\n )\n\n See also \u003ca href=\"../../tf/summary/scalar\"\u003e\u003ccode\u003etf.summary.scalar\u003c/code\u003e\u003c/a\u003e, \u003ca href=\"../../tf/summary/SummaryWriter\"\u003e\u003ccode\u003etf.summary.SummaryWriter\u003c/code\u003e\u003c/a\u003e, \u003ca href=\"../../tf/summary/image\"\u003e\u003ccode\u003etf.summary.image\u003c/code\u003e\u003c/a\u003e.\n\n Writes text Tensor values for later visualization and analysis in TensorBoard.\n Writes go to the current default summary writer. Like \u003ca href=\"../../tf/summary/scalar\"\u003e\u003ccode\u003etf.summary.scalar\u003c/code\u003e\u003c/a\u003e\n points, text points are each associated with a `step` and a `name`.\n All the points with the same `name` constitute a time series of text values.\n\n For Example:\n\n ```python\n test_summary_writer = tf.summary.create_file_writer('test/logdir')\n with test_summary_writer.as_default():\n tf.summary.text('first_text', 'hello world!', step=0)\n tf.summary.text('first_text', 'nice to meet you!', step=1)\n ```\n\n The text summary can also contain Markdown, and TensorBoard will render the text\n as such.\n\n ```python\n with test_summary_writer.as_default():\n text_data = '''\n | *hello* | *there* |\n |---------|---------|\n | this | is |\n | a | table |\n '''\n text_data = '\n\n'.join(l.strip() for l in text_data.splitlines())\ntf.summary.text('markdown_text', text_data, step=0)\n\\`\\`\\` \n\n Since text is Tensor valued, each text point may be a Tensor of string values.\n rank-1 and rank-2 Tensors are rendered as tables in TensorBoard. For higher ranked\n Tensors, you'll see just a 2D slice of the data. To avoid this, reshape the Tensor\n to at most rank-2 prior to passing it to this function.\n\n Demo notebook at\n [\"Displaying text data in TensorBoard\"](https://www.tensorflow.org/tensorboard/text_summaries).\n\n Arguments:\n name: A name for this summary. The summary tag used for TensorBoard will\n be this name prefixed by any active name scopes.\n data: A UTF-8 string Tensor value.\n step: Explicit `int64`-castable monotonic step value for this summary. If\n omitted, this defaults to \u003ca href=\"../../tf/summary/experimental/get_step\"\u003e\u003ccode\u003etf.summary.experimental.get_step()\u003c/code\u003e\u003c/a\u003e, which must\n not be None.\n description: Optional long-form description for this summary, as a\n constant `str`. Markdown is supported. Defaults to empty.\n\n Returns:\n True on success, or false if no summary was emitted because no default\n summary writer was available.\n\n Raises:\n ValueError: if a default writer exists, but no step was provided and\n \u003ca href=\"../../tf/summary/experimental/get_step\"\u003e\u003ccode\u003etf.summary.experimental.get_step()\u003c/code\u003e\u003c/a\u003e is None."]]