read_tensorboard_graph
read_tensorboard_graph(logdir, *, runs=None, expand_nested=False)Read the Keras model graphs of a TensorBoard log directory.
One chart per run that logged a model, as TensorBoard’s Graphs dashboard draws it under the Keras tag: one box per layer, top to bottom from the inputs, with an arrow from each layer to the layers called on its output.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| logdir | str or os.PathLike | The directory TensorBoard would be started with (--logdir), such as the log_dir of Keras’s TensorBoard callback with write_graph=True, its default. |
required |
| runs | iterable of str | Only these runs. Keras logs the model in its train run. |
None |
| expand_nested | bool | Whether a model used as a layer is drawn as its own layers, in a scope named for it, rather than as one box. | False |
Returns
| Name | Type | Description |
|---|---|---|
| list of TensorBoardChart | One per run, tagged keras. Pass one to :func:maidr.show, :func:maidr.render or :func:maidr.save_html. |
Raises
| Name | Type | Description |
|---|---|---|
| FileNotFoundError | If logdir is not a directory. |
Notes
The chart is a directed_graph, an experimental type that needs a maidr.js release carrying it. A run that logged its model more than once is drawn from the last. A model logged as something other than a Keras config, such as a TensorFlow op graph, is not read.
Examples
>>> import maidr
>>> (graph,) = maidr.read_tensorboard_graph("logs/fit")
>>> maidr.save_html(graph, "model.html")