diff options
author | Dandelion Mané <dandelion@google.com> | 2017-04-03 16:45:37 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-04-03 18:09:14 -0700 |
commit | b657f5a03a7490d961e10851fba193732f5e929c (patch) | |
tree | 4d43ba893bc0112ced84e134cf00ce0f3b848ee6 /tensorflow/python/summary | |
parent | 438c13ec9fae862bc5d416a6528035c961e02aee (diff) |
Modify the TensorBoard text dashboard so that it can support non-scalar string tensors.
If the string tensor passed to the text dashboard is not a scalar, then the data is automatically organized into a table.
Change: 152081823
Diffstat (limited to 'tensorflow/python/summary')
-rw-r--r-- | tensorflow/python/summary/text_summary.py | 15 | ||||
-rw-r--r-- | tensorflow/python/summary/text_summary_test.py | 16 |
2 files changed, 17 insertions, 14 deletions
diff --git a/tensorflow/python/summary/text_summary.py b/tensorflow/python/summary/text_summary.py index 82dee45d26..52bc913b2a 100644 --- a/tensorflow/python/summary/text_summary.py +++ b/tensorflow/python/summary/text_summary.py @@ -34,12 +34,17 @@ def text_summary(name, tensor, collections=None): """Summarizes textual data. Text data summarized via this plugin will be visible in the Text Dashboard - in TensorBoard. + in TensorBoard. The standard TensorBoard Text Dashboard will render markdown + in the strings, and will automatically organize 1d and 2d tensors into tables. + If a tensor with more than 2 dimensions is provided, a 2d subarray will be + displayed along with a warning message. (Note that this behavior is not + intrinsic to the text summary api, but rather to the default TensorBoard text + plugin.) Args: name: A name for the generated node. Will also serve as a series name in TensorBoard. - tensor: a scalar string-type Tensor to summarize. + tensor: a string-type Tensor to summarize. collections: Optional list of ops.GraphKeys. The collections to add the summary to. Defaults to [_ops.GraphKeys.SUMMARIES] @@ -49,16 +54,12 @@ def text_summary(name, tensor, collections=None): type `string` which contains `Summary` protobufs. Raises: - ValueError: If tensor has the wrong shape or type. + ValueError: If tensor has the wrong type. """ if tensor.dtype != dtypes.string: raise ValueError("Expected tensor %s to have dtype string, got %s" % (tensor.name, tensor.dtype)) - if tensor.shape.ndims != 0: - raise ValueError("Expected tensor %s to be scalar, has shape %s" % - (tensor.name, tensor.shape)) - t_summary = tensor_summary(name, tensor, collections=collections) text_assets = plugin_asset.get_plugin_asset(TextSummaryPluginAsset) text_assets.register_tensor(t_summary.op.name) diff --git a/tensorflow/python/summary/text_summary_test.py b/tensorflow/python/summary/text_summary_test.py index 69739573c1..31009702ca 100644 --- a/tensorflow/python/summary/text_summary_test.py +++ b/tensorflow/python/summary/text_summary_test.py @@ -40,17 +40,19 @@ class TextPluginTest(test_util.TensorFlowTestCase): num = array_ops.constant(1) text_summary.text_summary("foo", num) - with self.assertRaises(ValueError): - arr = array_ops.constant(["one", "two", "three"]) - text_summary.text_summary("foo", arr) + # The API accepts vectors. + arr = array_ops.constant(["one", "two", "three"]) + summ = text_summary.text_summary("foo", arr) + self.assertEqual(summ.op.type, "TensorSummary") + # the API accepts scalars summ = text_summary.text_summary("foo", array_ops.constant("one")) self.assertEqual(summ.op.type, "TensorSummary") - text_summary.text_summary("bar", array_ops.constant("2"), collections=[]) - summaries = framework_ops.get_collection( - framework_ops.GraphKeys.SUMMARIES) - self.assertEqual(len(summaries), 1) + def testTextSummaryCollections(self): + text_summary.text_summary("bar", array_ops.constant("2"), collections=[]) + summaries = framework_ops.get_collection(framework_ops.GraphKeys.SUMMARIES) + self.assertEqual(len(summaries), 0) if __name__ == "__main__": |