chainer.training.extensions.dump_graph¶
-
chainer.training.extensions.
dump_graph
(root_name, out_name='cg.dot', variable_style=None, function_style=None)[source]¶ Returns a trainer extension to dump a computational graph.
This extension dumps a computational graph. The graph is output in DOT language.
It only dumps a graph at the first invocation.
Note
As of v2.0.0, the computational graph is not kept by default. This extension changes this behavior until the first invocation. It is strongly recommended to use it with the default trigger setting.
The detailed behavior of this extension since v2.0.0 is as follows.
- In its initializer, it turns on the
chainer.config.keep_graph_on_report
flag. - At the first iteration, it dumps the graph using the graph held by the reported variable.
- After dumping the graph, it turns off the flag (if it was originally turned off) so that any variable reported afterward does not hold a computational graph.
When the
keep_graph_on_report
flag is turned on, the computational graph created by the updater is kept during the invocation of extensions. It will cause an unnecessarily large memory consumption when an extension also uses a large amount of memory, e.g.Evaluator
.With the default setting, the
dump_graph
extension is called at the first iteration. SinceEvaluator
is not called at the first iteration in most cases, it does not cause any memory problem.Parameters: - root_name (str) – Name of the root of the computational graph. The root variable is retrieved by this name from the observation dictionary of the trainer.
- out_name (str) – Output file name.
- variable_style (dict) – Dot node style for variables. Each variable is rendered by an octagon by default.
- function_style (dict) – Dot node style for functions. Each function is rendered by a rectangular by default.
See also
See
build_computational_graph()
for thevariable_style
andfunction_style
arguments.- In its initializer, it turns on the