|
22 | 22 | import collections
|
23 | 23 |
|
24 | 24 | import six
|
| 25 | +import numpy as np |
25 | 26 |
|
26 | 27 |
|
27 | 28 | @six.add_metaclass(abc.ABCMeta)
|
@@ -120,12 +121,56 @@ def read_scalars(
|
120 | 121 | """
|
121 | 122 | pass
|
122 | 123 |
|
123 |
| - def list_tensors(self): |
124 |
| - """Not yet specified.""" |
| 124 | + def list_tensors(self, experiment_id, plugin_name, run_tag_filter=None): |
| 125 | + """List metadata about tensor time series. |
| 126 | +
|
| 127 | + Args: |
| 128 | + experiment_id: ID of enclosing experiment. |
| 129 | + plugin_name: String name of the TensorBoard plugin that created |
| 130 | + the data to be queried. Required. |
| 131 | + run_tag_filter: Optional `RunTagFilter` value. If omitted, all |
| 132 | + runs and tags will be included. |
| 133 | +
|
| 134 | + The result will only contain keys for run-tag combinations that |
| 135 | + actually exist, which may not include all entries in the |
| 136 | + `run_tag_filter`. |
| 137 | +
|
| 138 | + Returns: |
| 139 | + A nested map `d` such that `d[run][tag]` is a `TensorTimeSeries` |
| 140 | + value. |
| 141 | +
|
| 142 | + Raises: |
| 143 | + tensorboard.errors.PublicError: See `DataProvider` class docstring. |
| 144 | + """ |
125 | 145 | pass
|
126 | 146 |
|
127 |
| - def read_tensors(self): |
128 |
| - """Not yet specified.""" |
| 147 | + def read_tensors( |
| 148 | + self, experiment_id, plugin_name, downsample=None, run_tag_filter=None |
| 149 | + ): |
| 150 | + """Read values from tensor time series. |
| 151 | +
|
| 152 | + Args: |
| 153 | + experiment_id: ID of enclosing experiment. |
| 154 | + plugin_name: String name of the TensorBoard plugin that created |
| 155 | + the data to be queried. Required. |
| 156 | + downsample: Integer number of steps to which to downsample the |
| 157 | + results (e.g., `1000`). Required. |
| 158 | + run_tag_filter: Optional `RunTagFilter` value. If provided, a time |
| 159 | + series will only be included in the result if its run and tag |
| 160 | + both pass this filter. If `None`, all time series will be |
| 161 | + included. |
| 162 | +
|
| 163 | + The result will only contain keys for run-tag combinations that |
| 164 | + actually exist, which may not include all entries in the |
| 165 | + `run_tag_filter`. |
| 166 | +
|
| 167 | + Returns: |
| 168 | + A nested map `d` such that `d[run][tag]` is a list of |
| 169 | + `TensorDatum` values sorted by step. |
| 170 | +
|
| 171 | + Raises: |
| 172 | + tensorboard.errors.PublicError: See `DataProvider` class docstring. |
| 173 | + """ |
129 | 174 | pass
|
130 | 175 |
|
131 | 176 | def list_blob_sequences(
|
@@ -392,6 +437,110 @@ def __repr__(self):
|
392 | 437 | ))
|
393 | 438 |
|
394 | 439 |
|
| 440 | +class TensorTimeSeries(_TimeSeries): |
| 441 | + """Metadata about a tensor time series for a particular run and tag. |
| 442 | +
|
| 443 | + Attributes: |
| 444 | + max_step: The largest step value of any datum in this tensor time series; a |
| 445 | + nonnegative integer. |
| 446 | + max_wall_time: The largest wall time of any datum in this time series, as |
| 447 | + `float` seconds since epoch. |
| 448 | + plugin_content: A bytestring of arbitrary plugin-specific metadata for this |
| 449 | + time series, as provided to `tf.summary.write` in the |
| 450 | + `plugin_data.content` field of the `metadata` argument. |
| 451 | + description: An optional long-form Markdown description, as a `str` that is |
| 452 | + empty if no description was specified. |
| 453 | + display_name: An optional long-form Markdown description, as a `str` that is |
| 454 | + empty if no description was specified. Deprecated; may be removed soon. |
| 455 | + """ |
| 456 | + |
| 457 | + def __eq__(self, other): |
| 458 | + if not isinstance(other, TensorTimeSeries): |
| 459 | + return False |
| 460 | + if self._max_step != other._max_step: |
| 461 | + return False |
| 462 | + if self._max_wall_time != other._max_wall_time: |
| 463 | + return False |
| 464 | + if self._plugin_content != other._plugin_content: |
| 465 | + return False |
| 466 | + if self._description != other._description: |
| 467 | + return False |
| 468 | + if self._display_name != other._display_name: |
| 469 | + return False |
| 470 | + return True |
| 471 | + |
| 472 | + def __hash__(self): |
| 473 | + return hash(( |
| 474 | + self._max_step, |
| 475 | + self._max_wall_time, |
| 476 | + self._plugin_content, |
| 477 | + self._description, |
| 478 | + self._display_name, |
| 479 | + )) |
| 480 | + |
| 481 | + def __repr__(self): |
| 482 | + return "TensorTimeSeries(%s)" % ", ".join(( |
| 483 | + "max_step=%r" % (self._max_step,), |
| 484 | + "max_wall_time=%r" % (self._max_wall_time,), |
| 485 | + "plugin_content=%r" % (self._plugin_content,), |
| 486 | + "description=%r" % (self._description,), |
| 487 | + "display_name=%r" % (self._display_name,), |
| 488 | + )) |
| 489 | + |
| 490 | + |
| 491 | +class TensorDatum(object): |
| 492 | + """A single datum in a tensor time series for a run and tag. |
| 493 | +
|
| 494 | + Attributes: |
| 495 | + step: The global step at which this datum occurred; an integer. This |
| 496 | + is a unique key among data of this time series. |
| 497 | + wall_time: The real-world time at which this datum occurred, as |
| 498 | + `float` seconds since epoch. |
| 499 | + numpy: The `numpy.ndarray` value with the tensor contents of this |
| 500 | + datum. |
| 501 | + """ |
| 502 | + |
| 503 | + __slots__ = ("_step", "_wall_time", "_numpy") |
| 504 | + |
| 505 | + def __init__(self, step, wall_time, numpy): |
| 506 | + self._step = step |
| 507 | + self._wall_time = wall_time |
| 508 | + self._numpy = numpy |
| 509 | + |
| 510 | + @property |
| 511 | + def step(self): |
| 512 | + return self._step |
| 513 | + |
| 514 | + @property |
| 515 | + def wall_time(self): |
| 516 | + return self._wall_time |
| 517 | + |
| 518 | + @property |
| 519 | + def numpy(self): |
| 520 | + return self._numpy |
| 521 | + |
| 522 | + def __eq__(self, other): |
| 523 | + if not isinstance(other, TensorDatum): |
| 524 | + return False |
| 525 | + if self._step != other._step: |
| 526 | + return False |
| 527 | + if self._wall_time != other._wall_time: |
| 528 | + return False |
| 529 | + if not np.array_equal(self._numpy, other._numpy): |
| 530 | + return False |
| 531 | + return True |
| 532 | + |
| 533 | + # Unhashable type: numpy arrays are mutable. |
| 534 | + __hash__ = None |
| 535 | + |
| 536 | + def __repr__(self): |
| 537 | + return "TensorDatum(%s)" % ", ".join(( |
| 538 | + "step=%r" % (self._step,), |
| 539 | + "wall_time=%r" % (self._wall_time,), |
| 540 | + "numpy=%r" % (self._numpy,), |
| 541 | + )) |
| 542 | + |
| 543 | + |
395 | 544 | class BlobSequenceTimeSeries(_TimeSeries):
|
396 | 545 | """Metadata about a blob sequence time series for a particular run and tag.
|
397 | 546 |
|
|
0 commit comments