Writes summaries for the given dictionary of values. This recursively creates subdirectories for any nested dictionaries provided in `summary_dict`, yielding a hierarchy of directories which will then be reflected in the TensorBoard UI as different colored curves. For example, user
(self, summary_dict)
| 67 | tf.nest.map_structure(tf.summary.flush, self._summary_writers) |
| 68 | |
| 69 | def write_summaries(self, summary_dict): |
| 70 | """Writes summaries for the given dictionary of values. |
| 71 | |
| 72 | This recursively creates subdirectories for any nested dictionaries |
| 73 | provided in `summary_dict`, yielding a hierarchy of directories which will |
| 74 | then be reflected in the TensorBoard UI as different colored curves. |
| 75 | |
| 76 | For example, users may evaluate on multiple datasets and return |
| 77 | `summary_dict` as a nested dictionary: |
| 78 | |
| 79 | { |
| 80 | "dataset1": { |
| 81 | "loss": loss1, |
| 82 | "accuracy": accuracy1 |
| 83 | }, |
| 84 | "dataset2": { |
| 85 | "loss": loss2, |
| 86 | "accuracy": accuracy2 |
| 87 | }, |
| 88 | } |
| 89 | |
| 90 | This will create two subdirectories, "dataset1" and "dataset2", inside the |
| 91 | summary root directory. Each directory will contain event files including |
| 92 | both "loss" and "accuracy" summaries. |
| 93 | |
| 94 | Args: |
| 95 | summary_dict: A dictionary of values. If any value in `summary_dict` is |
| 96 | itself a dictionary, then the function will create a subdirectory with |
| 97 | name given by the corresponding key. This is performed recursively. Leaf |
| 98 | values are then summarized using the summary writer instance specific to |
| 99 | the parent relative path. |
| 100 | """ |
| 101 | if not self._enabled: |
| 102 | return |
| 103 | self._write_summaries(summary_dict) |
| 104 | |
| 105 | def _write_summaries(self, summary_dict, relative_path=""): |
| 106 | for name, value in summary_dict.items(): |
no test coverage detected