Skip to content

Latest commit

 

History

History
1645 lines (787 loc) · 38.7 KB

File metadata and controls

1645 lines (787 loc) · 38.7 KB

TensorFlow Debugger

[TOC]

Public Python API of TensorFlow Debugger (tfdbg).

Functions for adding debug watches

These functions help you modify RunOptions to specify which Tensors are to be watched when the TensorFlow graph is executed at runtime.


tf_debug.add_debug_tensor_watch(run_options, node_name, output_slot=0, debug_ops='DebugIdentity', debug_urls=None) {#add_debug_tensor_watch}

Add watch on a Tensor to RunOptions.

N.B.: Under certain circumstances, the Tensor may not be actually watched (e.g., if the node of the Tensor is constant-folded during runtime).

Args:
  • run_options: An instance of config_pb2.RunOptions to be modified.
  • node_name: (str) name of the node to watch.
  • output_slot: (int) output slot index of the tensor from the watched node.
  • debug_ops: (str or list of str) name(s) of the debug op(s). Can be a list of str or a single str. The latter case is equivalent to a list of str with only one element.
  • debug_urls: (str or list of str) URL(s) to send debug values to, e.g., file:///tmp/tfdbg_dump_1, grpc://localhost:12345.

tf_debug.watch_graph(run_options, graph, debug_ops='DebugIdentity', debug_urls=None, node_name_regex_whitelist=None, op_type_regex_whitelist=None) {#watch_graph}

Add debug watches to RunOptions for a TensorFlow graph.

To watch all Tensors on the graph, let both node_name_regex_whitelist and op_type_regex_whitelist be the default (None).

N.B.: Under certain circumstances, not all specified Tensors will be actually watched (e.g., nodes that are constant-folded during runtime will not be watched).

Args:
  • run_options: An instance of config_pb2.RunOptions to be modified.
  • graph: An instance of ops.Graph.
  • debug_ops: (str or list of str) name(s) of the debug op(s) to use.
  • debug_urls: URLs to send debug values to. Can be a list of strings, a single string, or None. The case of a single string is equivalent to a list consisting of a single string, e.g., file:///tmp/tfdbg_dump_1, grpc://localhost:12345.
  • node_name_regex_whitelist: Regular-expression whitelist for node_name, e.g., "(weight_[0-9]+|bias_.*)"
  • op_type_regex_whitelist: Regular-expression whitelist for the op type of nodes, e.g., "(Variable|Add)". If both node_name_regex_whitelist and op_type_regex_whitelist are set, the two filtering operations will occur in a logical AND relation. In other words, a node will be included if and only if it hits both whitelists.

tf_debug.watch_graph_with_blacklists(run_options, graph, debug_ops='DebugIdentity', debug_urls=None, node_name_regex_blacklist=None, op_type_regex_blacklist=None) {#watch_graph_with_blacklists}

Add debug tensor watches, blacklisting nodes and op types.

This is similar to watch_graph(), but the node names and op types are blacklisted, instead of whitelisted.

N.B.: Under certain circumstances, not all specified Tensors will be actually watched (e.g., nodes that are constant-folded during runtime will not be watched).

Args:
  • run_options: An instance of config_pb2.RunOptions to be modified.
  • graph: An instance of ops.Graph.
  • debug_ops: (str or list of str) name(s) of the debug op(s) to use.
  • debug_urls: URL(s) to send ebug values to, e.g., file:///tmp/tfdbg_dump_1, grpc://localhost:12345.
  • node_name_regex_blacklist: Regular-expression blacklist for node_name. This should be a string, e.g., "(weight_[0-9]+|bias_.*)".
  • op_type_regex_blacklist: Regular-expression blacklist for the op type of nodes, e.g., "(Variable|Add)". If both node_name_regex_blacklist and op_type_regex_blacklist are set, the two filtering operations will occur in a logical OR relation. In other words, a node will be excluded if it hits either of the two blacklists; a node will be included if and only if it hits neither of the blacklists.

Classes for debug-dump data and directories

These classes allow you to load and inspect tensor values dumped from TensorFlow graphs during runtime.


class tf_debug.DebugTensorDatum {#DebugTensorDatum}

A single tensor dumped by TensorFlow Debugger (tfdbg).

Contains metadata about the dumped tensor, including timestamp, node_name, output_slot, debug_op, and path to the dump file (file_path).

This type does not hold the generally space-expensive tensor value (numpy array). Instead, it points to the file from which the tensor value can be loaded (with the get_tensor method) if needed.


tf_debug.DebugTensorDatum.__init__(dump_root, debug_dump_rel_path) {#DebugTensorDatum.init}

DebugTensorDatum constructor.

Args:
  • dump_root: (str) Debug dump root directory.
  • debug_dump_rel_path: (str) Path to a debug dump file, relative to the dump_root. For example, suppose the debug dump root directory is /tmp/tfdbg_1 and the dump file is at /tmp/tfdbg_1/ns_1/node_a_0_DebugIdentity_123456789, then the value of the debug_dump_rel_path should be ns_1/node_a_0_DebugIdenity_1234456789.
Raises:
  • ValueError: If the base file name of the dump file does not conform to the dump file naming pattern: node_nameoutput_slotdebug_op_timestamp

tf_debug.DebugTensorDatum.__repr__() {#DebugTensorDatum.repr}


tf_debug.DebugTensorDatum.__str__() {#DebugTensorDatum.str}


tf_debug.DebugTensorDatum.debug_op {#DebugTensorDatum.debug_op}

Name of the debug op.

Returns:

(str) debug op name (e.g., DebugIdentity).


tf_debug.DebugTensorDatum.dump_size_bytes {#DebugTensorDatum.dump_size_bytes}

Size of the dump file.

Unit: byte.

Returns:

If the dump file exists, size of the dump file, in bytes. If the dump file does not exist, None.


tf_debug.DebugTensorDatum.file_path {#DebugTensorDatum.file_path}

Path to the file which stores the value of the dumped tensor.


tf_debug.DebugTensorDatum.get_tensor() {#DebugTensorDatum.get_tensor}

Get tensor from the dump (Event) file.

Returns:

The tensor loaded from the dump (Event) file.


tf_debug.DebugTensorDatum.node_name {#DebugTensorDatum.node_name}

Name of the node from which the tensor value was dumped.

Returns:

(str) name of the node watched by the debug op.


tf_debug.DebugTensorDatum.output_slot {#DebugTensorDatum.output_slot}

Output slot index from which the tensor value was dumped.

Returns:

(int) output slot index watched by the debug op.


tf_debug.DebugTensorDatum.tensor_name {#DebugTensorDatum.tensor_name}

Name of the tensor watched by the debug op.

Returns:

(str) Tensor name, in the form of node_name:output_slot


tf_debug.DebugTensorDatum.timestamp {#DebugTensorDatum.timestamp}

Timestamp of when this tensor value was dumped.

Returns:

(int) The timestamp in microseconds.


tf_debug.DebugTensorDatum.watch_key {#DebugTensorDatum.watch_key}

Watch key identities a debug watch on a tensor.

Returns:

(str) A watch key, in the form of tensor_name:debug_op.


class tf_debug.DebugDumpDir {#DebugDumpDir}

Data set from a debug-dump directory on filesystem.

An instance of DebugDumpDir contains all DebugTensorDatum instances in a tfdbg dump root directory.


tf_debug.DebugDumpDir.__init__(dump_root, partition_graphs=None, validate=True) {#DebugDumpDir.init}

DebugDumpDir constructor.

Args:
  • dump_root: (str) path to the dump root directory.
  • partition_graphs: A repeated field of GraphDefs representing the partition graphs executed by the TensorFlow runtime.
  • validate: (bool) whether the dump files are to be validated against the partition graphs.
Raises:
  • IOError: If dump_root does not exist as a directory.

tf_debug.DebugDumpDir.debug_watch_keys(node_name) {#DebugDumpDir.debug_watch_keys}

Get all tensor watch keys of given node according to partition graphs.

Args:
  • node_name: (str) name of the node.
Returns:

(list of str) all debug tensor watch keys. Returns an empty list if the node name does not correspond to any debug watch keys.

Raises:

LookupError: If debug watch information has not been loaded from partition graphs yet.


tf_debug.DebugDumpDir.devices() {#DebugDumpDir.devices}

Get the list of devices.

Returns:

(list of str) names of the devices.

Raises:
  • LookupError: If node inputs and control inputs have not been loaded from partition graphs yet.

tf_debug.DebugDumpDir.dumped_tensor_data {#DebugDumpDir.dumped_tensor_data}


tf_debug.DebugDumpDir.find(predicate, first_n=0) {#DebugDumpDir.find}

Find dumped tensor data by a certain predicate.

Args:
  • predicate: A callable that takes two input arguments:

    def predicate(debug_tensor_datum, tensor):
      # returns a bool

    where debug_tensor_datum is an instance of DebugTensorDatum, which carries the metadata, such as the Tensor's node name, output slot timestamp, debug op name, etc.; and tensor is the dumped tensor value as a numpy.ndarray.

  • first_n: (int) return only the first n DebugTensotDatum instances (in time order) for which the predicate returns True. To return all the DebugTensotDatum instances, let first_n be <= 0.

Returns:

A list of all DebugTensorDatum objects in this DebugDumpDir object for which predicate returns True, sorted in ascending order of the timestamp.


tf_debug.DebugDumpDir.get_dump_sizes_bytes(node_name, output_slot, debug_op) {#DebugDumpDir.get_dump_sizes_bytes}

Get the sizes of the dump files for a debug-dumped tensor.

Unit of the file size: byte.

Args:
  • node_name: (str) name of the node that the tensor is produced by.
  • output_slot: (int) output slot index of tensor.
  • debug_op: (str) name of the debug op.
Returns:

(list of int): list of dump file sizes in bytes.

Raises:
  • ValueError: If the tensor watch key does not exist in the debug dump data.

tf_debug.DebugDumpDir.get_rel_timestamps(node_name, output_slot, debug_op) {#DebugDumpDir.get_rel_timestamps}

Get the relative timestamp from for a debug-dumped tensor.

Relative timestamp means (absolute timestamp - t0), where t0 is the absolute timestamp of the first dumped tensor in the dump root. The tensor may be dumped multiple times in the dump root directory, so a list of relative timestamps (numpy.ndarray) is returned.

Args:
  • node_name: (str) name of the node that the tensor is produced by.
  • output_slot: (int) output slot index of tensor.
  • debug_op: (str) name of the debug op.
Returns:

(list of int) list of relative timestamps.

Raises:
  • ValueError: If the tensor watch key does not exist in the debug dump data.

tf_debug.DebugDumpDir.get_tensor_file_paths(node_name, output_slot, debug_op) {#DebugDumpDir.get_tensor_file_paths}

Get the file paths from a debug-dumped tensor.

Args:
  • node_name: (str) name of the node that the tensor is produced by.
  • output_slot: (int) output slot index of tensor.
  • debug_op: (str) name of the debug op.
Returns:

List of file path(s) loaded. This is a list because each debugged tensor may be dumped multiple times.

Raises:
  • ValueError: If the tensor does not exist in the debug-dump data.

tf_debug.DebugDumpDir.get_tensors(node_name, output_slot, debug_op) {#DebugDumpDir.get_tensors}

Get the tensor value from for a debug-dumped tensor.

The tensor may be dumped multiple times in the dump root directory, so a list of tensors (numpy.ndarray) is returned.

Args:
  • node_name: (str) name of the node that the tensor is produced by.
  • output_slot: (int) output slot index of tensor.
  • debug_op: (str) name of the debug op.
Returns:

List of tensors (numpy.ndarray) loaded from the debug-dump file(s).

Raises:
  • ValueError: If the tensor does not exist in the debug-dump data.

tf_debug.DebugDumpDir.loaded_partition_graphs() {#DebugDumpDir.loaded_partition_graphs}

Test whether partition graphs have been loaded.


tf_debug.DebugDumpDir.node_attributes(node_name) {#DebugDumpDir.node_attributes}

Get the attributes of a node.

Args:
  • node_name: Name of the node in question.
Returns:

Attributes of the node.

Raises:
  • LookupError: If no partition graphs have been loaded.
  • ValueError: If no node named node_name exists.

tf_debug.DebugDumpDir.node_device(node_name) {#DebugDumpDir.node_device}

Get the device of a node.

Args:
  • node_name: (str) name of the node.
Returns:

(str) name of the device on which the node is placed.

Raises:
  • LookupError: If node inputs and control inputs have not been loaded from partition graphs yet.
  • ValueError: If the node does not exist in partition graphs.

tf_debug.DebugDumpDir.node_exists(node_name) {#DebugDumpDir.node_exists}

Test if a node exists in the partition graphs.

Args:
  • node_name: (str) name of the node to be checked.
Returns:

A boolean indicating whether the node exists.

Raises:
  • LookupError: If no partition graphs have been loaded yet.

tf_debug.DebugDumpDir.node_inputs(node_name, is_control=False) {#DebugDumpDir.node_inputs}

Get the inputs of given node according to partition graphs.

Args:
  • node_name: Name of the node.
  • is_control: (bool) Whether control inputs, rather than non-control inputs, are to be returned.
Returns:

(list of str) inputs to the node, as a list of node names.

Raises:
  • LookupError: If node inputs and control inputs have not been loaded from partition graphs yet.
  • ValueError: If the node does not exist in partition graphs.

tf_debug.DebugDumpDir.node_op_type(node_name) {#DebugDumpDir.node_op_type}

Get the op type of given node.

Args:
  • node_name: (str) name of the node.
Returns:

(str) op type of the node.

Raises:
  • LookupError: If node op types have not been loaded from partition graphs yet.
  • ValueError: If the node does not exist in partition graphs.

tf_debug.DebugDumpDir.node_recipients(node_name, is_control=False) {#DebugDumpDir.node_recipients}

Get recipient of the given node's output according to partition graphs.

Args:
  • node_name: (str) name of the node.
  • is_control: (bool) whether control outputs, rather than non-control outputs, are to be returned.
Returns:

(list of str) all inputs to the node, as a list of node names.

Raises:
  • LookupError: If node inputs and control inputs have not been loaded from partition graphs yet.
  • ValueError: If the node does not exist in partition graphs.

tf_debug.DebugDumpDir.node_traceback(element_name) {#DebugDumpDir.node_traceback}

Try to retrieve the Python traceback of node's construction.

Args:
  • element_name: (str) Name of a graph element (node or tensor).
Returns:

(list) The traceback list object as returned by the extract_trace method of Python's traceback module.

Raises:
  • LookupError: If Python graph is not available for traceback lookup.
  • KeyError: If the node cannot be found in the Python graph loaded.

tf_debug.DebugDumpDir.nodes() {#DebugDumpDir.nodes}

Get a list of all nodes from the partition graphs.

Returns:

All nodes' names, as a list of str.

Raises:
  • LookupError: If no partition graphs have been loaded.

tf_debug.DebugDumpDir.partition_graphs() {#DebugDumpDir.partition_graphs}

Get the partition graphs.

Returns:

Partition graphs as repeated fields of GraphDef.

Raises:
  • LookupError: If no partition graphs have been loaded.

tf_debug.DebugDumpDir.run_feed_keys_info {#DebugDumpDir.run_feed_keys_info}

Get a str representation of the feed_dict used in the Session.run() call.

Returns:

If the information is available, a str obtained from repr(feed_dict). If the information is not available, None.


tf_debug.DebugDumpDir.run_fetches_info {#DebugDumpDir.run_fetches_info}

Get a str representation of the fetches used in the Session.run() call.

Returns:

If the information is available, a str obtained from repr(fetches). If the information is not available, None.


tf_debug.DebugDumpDir.set_python_graph(python_graph) {#DebugDumpDir.set_python_graph}

Provide Python Graph object to the wrapper.

Unlike the partition graphs, which are protobuf GraphDef objects, Graph is a Python object and carries additional information such as the traceback of the construction of the nodes in the graph.

Args:
  • python_graph: (ops.Graph) The Python Graph object.

tf_debug.DebugDumpDir.size {#DebugDumpDir.size}

Total number of dumped tensors in the dump root directory.

Returns:

(int) total number of dumped tensors in the dump root directory.


tf_debug.DebugDumpDir.t0 {#DebugDumpDir.t0}

Absolute timestamp of the first dumped tensor.

Returns:

(int) absolute timestamp of the first dumped tensor, in microseconds.


tf_debug.DebugDumpDir.transitive_inputs(node_name, include_control=True) {#DebugDumpDir.transitive_inputs}

Get the transitive inputs of given node according to partition graphs.

Args:
  • node_name: Name of the node
  • include_control: Include control inputs (True by default).
Returns:

(list of str) all transitive inputs to the node, as a list of node names.

Raises:
  • LookupError: If node inputs and control inputs have not been loaded from partition graphs yet.
  • ValueError: If the node does not exist in partition graphs.

tf_debug.DebugDumpDir.watch_key_to_data(debug_watch_key) {#DebugDumpDir.watch_key_to_data}

Get all DebugTensorDatum instances corresponding to a debug watch key.

Args:
  • debug_watch_key: (str) debug watch key.
Returns:

A list of DebugTensorDatum instances that correspond to the debug watch key. If the watch key does not exist, returns an empty list.

Raises:
  • ValueError: If the debug watch key does not exist.

Functions for loading debug-dump data


tf_debug.load_tensor_from_event_file(event_file_path) {#load_tensor_from_event_file}

Load a tensor from an event file.

Assumes that the event file contains a Event protobuf and the Event protobuf contains a Tensor value.

Args:
  • event_file_path: (str) path to the event file.
Returns:

The tensor value loaded from the event file, as a numpy.ndarray. For uninitialized tensors, returns None.

Tensor-value predicates

Built-in tensor-filter predicates to support conditional breakpoint between runs. See DebugDumpDir.find() for more details.


tf_debug.has_inf_or_nan(datum, tensor) {#has_inf_or_nan}

A predicate for whether a tensor consists of any bad numerical values.

This predicate is common enough to merit definition in this module. Bad numerical values include nans and infs. The signature of this function follows the requirement of the method DebugDumpDir.find().

Args:
  • datum: (DebugTensorDatum) Datum metadata.
  • tensor: (numpy.ndarray or None) Value of the tensor. None represents an uninitialized tensor.
Returns:

(bool) True if and only if tensor consists of any nan or inf values.

Session wrapper class and SessionRunHook implementations

These classes allow you to

  • wrap aroundTensorFlow Session objects to debug plain TensorFlow models (see DumpingDebugWrapperSession and LocalCLIDebugWrapperSession), or
  • generate SessionRunHook objects to debug tf.contrib.learn models (see DumpingDebugHook and LocalCLIDebugHook).

class tf_debug.DumpingDebugHook {#DumpingDebugHook}

A debugger hook that dumps debug data to filesystem.

Can be used as a monitor/hook for tf.train.MonitoredSessions and tf.contrib.learn's Estimators and Experiments.


tf_debug.DumpingDebugHook.__enter__() {#DumpingDebugHook.enter}


tf_debug.DumpingDebugHook.__exit__(exec_type, exec_value, exec_tb) {#DumpingDebugHook.exit}


tf_debug.DumpingDebugHook.__init__(session_root, watch_fn=None, log_usage=True) {#DumpingDebugHook.init}

Create a local debugger command-line interface (CLI) hook.

Args:
  • session_root: See doc of dumping_wrapper.DumpingDebugWrapperSession.__init__.
  • watch_fn: See doc of dumping_wrapper.DumpingDebugWrapperSession.__init__.
  • log_usage: (bool) Whether usage is to be logged.

tf_debug.DumpingDebugHook.after_create_session(session, coord) {#DumpingDebugHook.after_create_session}

Called when new TensorFlow session is created.

This is called to signal the hooks that a new session has been created. This has two essential differences with the situation in which begin is called:

  • When this is called, the graph is finalized and ops can no longer be added to the graph.
  • This method will also be called as a result of recovering a wrapped session, not only at the beginning of the overall session.
Args:
  • session: A TensorFlow Session that has been created.
  • coord: A Coordinator object which keeps track of all threads.

tf_debug.DumpingDebugHook.after_run(run_context, run_values) {#DumpingDebugHook.after_run}


tf_debug.DumpingDebugHook.before_run(run_context) {#DumpingDebugHook.before_run}


tf_debug.DumpingDebugHook.begin() {#DumpingDebugHook.begin}


tf_debug.DumpingDebugHook.close() {#DumpingDebugHook.close}


tf_debug.DumpingDebugHook.end(session) {#DumpingDebugHook.end}

Called at the end of session.

The session argument can be used in case the hook wants to run final ops, such as saving a last checkpoint.

Args:
  • session: A TensorFlow Session that will be soon closed.

tf_debug.DumpingDebugHook.graph {#DumpingDebugHook.graph}


tf_debug.DumpingDebugHook.invoke_node_stepper(node_stepper, restore_variable_values_on_exit=True) {#DumpingDebugHook.invoke_node_stepper}

See doc of BaseDebugWrapperSession.invoke_node_stepper.


tf_debug.DumpingDebugHook.on_run_end(request) {#DumpingDebugHook.on_run_end}

See doc of BaseDebugWrapperSession.on_run_end.


tf_debug.DumpingDebugHook.on_run_start(request) {#DumpingDebugHook.on_run_start}

See doc of BaseDebugWrapperSession.on_run_start.


tf_debug.DumpingDebugHook.on_session_init(request) {#DumpingDebugHook.on_session_init}

See doc of BaseDebugWrapperSession.on_run_start.


tf_debug.DumpingDebugHook.partial_run(handle, fetches, feed_dict=None) {#DumpingDebugHook.partial_run}


tf_debug.DumpingDebugHook.partial_run_setup(fetches, feeds=None) {#DumpingDebugHook.partial_run_setup}

Sets up the feeds and fetches for partial runs in the session.


tf_debug.DumpingDebugHook.run(fetches, feed_dict=None, options=None, run_metadata=None) {#DumpingDebugHook.run}

Wrapper around Session.run() that inserts tensor watch options.

Args:
  • fetches: Same as the fetches arg to regular Session.run().
  • feed_dict: Same as the feed_dict arg to regular Session.run().
  • options: Same as the options arg to regular Session.run().
  • run_metadata: Same as the run_metadata arg to regular Session.run().
Returns:

Simply forwards the output of the wrapped Session.run() call.

Raises:
  • ValueError: On invalid OnRunStartAction value.

tf_debug.DumpingDebugHook.sess_str {#DumpingDebugHook.sess_str}


tf_debug.DumpingDebugHook.session {#DumpingDebugHook.session}


class tf_debug.DumpingDebugWrapperSession {#DumpingDebugWrapperSession}

Debug Session wrapper that dumps debug data to filesystem.


tf_debug.DumpingDebugWrapperSession.__enter__() {#DumpingDebugWrapperSession.enter}


tf_debug.DumpingDebugWrapperSession.__exit__(exec_type, exec_value, exec_tb) {#DumpingDebugWrapperSession.exit}


tf_debug.DumpingDebugWrapperSession.__init__(sess, session_root, watch_fn=None, log_usage=True) {#DumpingDebugWrapperSession.init}

Constructor of DumpingDebugWrapperSession.

Args:
  • sess: The TensorFlow Session object being wrapped.
  • session_root: (str) Path to the session root directory. Must be a directory that does not exist or an empty directory. If the directory does not exist, it will be created by the debugger core during debug Session.run() calls. As the run() calls occur, subdirectories will be added to session_root. The subdirectories' names has the following pattern: run_<epoch_time_stamp>_ E.g., run_1480734393835964_ad4c953a85444900ae79fc1b652fb324
  • watch_fn: (Callable) A Callable that can be used to define per-run debug ops and watched tensors. See the doc of NonInteractiveDebugWrapperSession.__init__() for details.
  • log_usage: (bool) whether the usage of this class is to be logged.
Raises:
  • ValueError: If session_root is an existing and non-empty directory or if session_root is a file.

tf_debug.DumpingDebugWrapperSession.close() {#DumpingDebugWrapperSession.close}


tf_debug.DumpingDebugWrapperSession.graph {#DumpingDebugWrapperSession.graph}


tf_debug.DumpingDebugWrapperSession.invoke_node_stepper(node_stepper, restore_variable_values_on_exit=True) {#DumpingDebugWrapperSession.invoke_node_stepper}

See doc of BaseDebugWrapperSession.invoke_node_stepper.


tf_debug.DumpingDebugWrapperSession.on_run_end(request) {#DumpingDebugWrapperSession.on_run_end}

See doc of BaseDebugWrapperSession.on_run_end.


tf_debug.DumpingDebugWrapperSession.on_run_start(request) {#DumpingDebugWrapperSession.on_run_start}

See doc of BaseDebugWrapperSession.on_run_start.


tf_debug.DumpingDebugWrapperSession.on_session_init(request) {#DumpingDebugWrapperSession.on_session_init}

See doc of BaseDebugWrapperSession.on_run_start.


tf_debug.DumpingDebugWrapperSession.partial_run(handle, fetches, feed_dict=None) {#DumpingDebugWrapperSession.partial_run}


tf_debug.DumpingDebugWrapperSession.partial_run_setup(fetches, feeds=None) {#DumpingDebugWrapperSession.partial_run_setup}

Sets up the feeds and fetches for partial runs in the session.


tf_debug.DumpingDebugWrapperSession.run(fetches, feed_dict=None, options=None, run_metadata=None) {#DumpingDebugWrapperSession.run}

Wrapper around Session.run() that inserts tensor watch options.

Args:
  • fetches: Same as the fetches arg to regular Session.run().
  • feed_dict: Same as the feed_dict arg to regular Session.run().
  • options: Same as the options arg to regular Session.run().
  • run_metadata: Same as the run_metadata arg to regular Session.run().
Returns:

Simply forwards the output of the wrapped Session.run() call.

Raises:
  • ValueError: On invalid OnRunStartAction value.

tf_debug.DumpingDebugWrapperSession.sess_str {#DumpingDebugWrapperSession.sess_str}


tf_debug.DumpingDebugWrapperSession.session {#DumpingDebugWrapperSession.session}


class tf_debug.LocalCLIDebugHook {#LocalCLIDebugHook}

Command-line-interface debugger hook.

Can be used as a monitor/hook for tf.train.MonitoredSessions and tf.contrib.learn's Estimators and Experiments.


tf_debug.LocalCLIDebugHook.__enter__() {#LocalCLIDebugHook.enter}


tf_debug.LocalCLIDebugHook.__exit__(exec_type, exec_value, exec_tb) {#LocalCLIDebugHook.exit}


tf_debug.LocalCLIDebugHook.__init__(ui_type='curses') {#LocalCLIDebugHook.init}

Create a local debugger command-line interface (CLI) hook.

Args:
  • ui_type: (str) user-interface type.

tf_debug.LocalCLIDebugHook.add_tensor_filter(filter_name, tensor_filter) {#LocalCLIDebugHook.add_tensor_filter}

Add a tensor filter.

Args:
  • filter_name: (str) name of the filter.
  • tensor_filter: (callable) the filter callable. See the doc string of DebugDumpDir.find() for more details about its signature.

tf_debug.LocalCLIDebugHook.after_create_session(session, coord) {#LocalCLIDebugHook.after_create_session}

Called when new TensorFlow session is created.

This is called to signal the hooks that a new session has been created. This has two essential differences with the situation in which begin is called:

  • When this is called, the graph is finalized and ops can no longer be added to the graph.
  • This method will also be called as a result of recovering a wrapped session, not only at the beginning of the overall session.
Args:
  • session: A TensorFlow Session that has been created.
  • coord: A Coordinator object which keeps track of all threads.

tf_debug.LocalCLIDebugHook.after_run(run_context, run_values) {#LocalCLIDebugHook.after_run}


tf_debug.LocalCLIDebugHook.before_run(run_context) {#LocalCLIDebugHook.before_run}


tf_debug.LocalCLIDebugHook.begin() {#LocalCLIDebugHook.begin}


tf_debug.LocalCLIDebugHook.close() {#LocalCLIDebugHook.close}


tf_debug.LocalCLIDebugHook.end(session) {#LocalCLIDebugHook.end}

Called at the end of session.

The session argument can be used in case the hook wants to run final ops, such as saving a last checkpoint.

Args:
  • session: A TensorFlow Session that will be soon closed.

tf_debug.LocalCLIDebugHook.graph {#LocalCLIDebugHook.graph}


tf_debug.LocalCLIDebugHook.invoke_node_stepper(node_stepper, restore_variable_values_on_exit=True) {#LocalCLIDebugHook.invoke_node_stepper}

Overrides method in base class to implement interactive node stepper.

Args:
  • node_stepper: (stepper.NodeStepper) The underlying NodeStepper API object.
  • restore_variable_values_on_exit: (bool) Whether any variables whose values have been altered during this node-stepper invocation should be restored to their old values when this invocation ends.
Returns:

The same return values as the Session.run() call on the same fetches as the NodeStepper.


tf_debug.LocalCLIDebugHook.on_run_end(request) {#LocalCLIDebugHook.on_run_end}

Overrides on-run-end callback.

Actions taken:
  1. Load the debug dump.
  2. Bring up the Analyzer CLI.
Args:
  • request: An instance of OnSessionInitRequest.
Returns:

An instance of OnSessionInitResponse.


tf_debug.LocalCLIDebugHook.on_run_start(request) {#LocalCLIDebugHook.on_run_start}

Overrides on-run-start callback.

Invoke the CLI to let user choose what action to take:

run / invoke_stepper.

Args:
  • request: An instance of OnSessionInitRequest.
Returns:

An instance of OnSessionInitResponse.

Raises:
  • RuntimeError: If user chooses to prematurely exit the debugger.

tf_debug.LocalCLIDebugHook.on_session_init(request) {#LocalCLIDebugHook.on_session_init}

Overrides on-session-init callback.

Args:
  • request: An instance of OnSessionInitRequest.
Returns:

An instance of OnSessionInitResponse.


tf_debug.LocalCLIDebugHook.partial_run(handle, fetches, feed_dict=None) {#LocalCLIDebugHook.partial_run}


tf_debug.LocalCLIDebugHook.partial_run_setup(fetches, feeds=None) {#LocalCLIDebugHook.partial_run_setup}

Sets up the feeds and fetches for partial runs in the session.


tf_debug.LocalCLIDebugHook.run(fetches, feed_dict=None, options=None, run_metadata=None) {#LocalCLIDebugHook.run}

Wrapper around Session.run() that inserts tensor watch options.

Args:
  • fetches: Same as the fetches arg to regular Session.run().
  • feed_dict: Same as the feed_dict arg to regular Session.run().
  • options: Same as the options arg to regular Session.run().
  • run_metadata: Same as the run_metadata arg to regular Session.run().
Returns:

Simply forwards the output of the wrapped Session.run() call.

Raises:
  • ValueError: On invalid OnRunStartAction value.

tf_debug.LocalCLIDebugHook.sess_str {#LocalCLIDebugHook.sess_str}


tf_debug.LocalCLIDebugHook.session {#LocalCLIDebugHook.session}


class tf_debug.LocalCLIDebugWrapperSession {#LocalCLIDebugWrapperSession}

Concrete subclass of BaseDebugWrapperSession implementing a local CLI.

This class has all the methods that a session.Session object has, in order to support debugging with minimal code changes. Invoking its run() method will launch the command-line interface (CLI) of tfdbg.


tf_debug.LocalCLIDebugWrapperSession.__enter__() {#LocalCLIDebugWrapperSession.enter}


tf_debug.LocalCLIDebugWrapperSession.__exit__(exec_type, exec_value, exec_tb) {#LocalCLIDebugWrapperSession.exit}


tf_debug.LocalCLIDebugWrapperSession.__init__(sess, dump_root=None, log_usage=True, ui_type='curses') {#LocalCLIDebugWrapperSession.init}

Constructor of LocalCLIDebugWrapperSession.

Args:
  • sess: The TensorFlow Session object being wrapped.
  • dump_root: (str) optional path to the dump root directory. Must be a directory that does not exist or an empty directory. If the directory does not exist, it will be created by the debugger core during debug run() calls and removed afterwards.
  • log_usage: (bool) whether the usage of this class is to be logged.
  • ui_type: (str) requested UI type. Currently supported: (curses | readline)
Raises:
  • ValueError: If dump_root is an existing and non-empty directory or if dump_root is a file.

tf_debug.LocalCLIDebugWrapperSession.add_tensor_filter(filter_name, tensor_filter) {#LocalCLIDebugWrapperSession.add_tensor_filter}

Add a tensor filter.

Args:
  • filter_name: (str) name of the filter.
  • tensor_filter: (callable) the filter callable. See the doc string of DebugDumpDir.find() for more details about its signature.

tf_debug.LocalCLIDebugWrapperSession.close() {#LocalCLIDebugWrapperSession.close}


tf_debug.LocalCLIDebugWrapperSession.graph {#LocalCLIDebugWrapperSession.graph}


tf_debug.LocalCLIDebugWrapperSession.invoke_node_stepper(node_stepper, restore_variable_values_on_exit=True) {#LocalCLIDebugWrapperSession.invoke_node_stepper}

Overrides method in base class to implement interactive node stepper.

Args:
  • node_stepper: (stepper.NodeStepper) The underlying NodeStepper API object.
  • restore_variable_values_on_exit: (bool) Whether any variables whose values have been altered during this node-stepper invocation should be restored to their old values when this invocation ends.
Returns:

The same return values as the Session.run() call on the same fetches as the NodeStepper.


tf_debug.LocalCLIDebugWrapperSession.on_run_end(request) {#LocalCLIDebugWrapperSession.on_run_end}

Overrides on-run-end callback.

Actions taken:
  1. Load the debug dump.
  2. Bring up the Analyzer CLI.
Args:
  • request: An instance of OnSessionInitRequest.
Returns:

An instance of OnSessionInitResponse.


tf_debug.LocalCLIDebugWrapperSession.on_run_start(request) {#LocalCLIDebugWrapperSession.on_run_start}

Overrides on-run-start callback.

Invoke the CLI to let user choose what action to take:

run / invoke_stepper.

Args:
  • request: An instance of OnSessionInitRequest.
Returns:

An instance of OnSessionInitResponse.

Raises:
  • RuntimeError: If user chooses to prematurely exit the debugger.

tf_debug.LocalCLIDebugWrapperSession.on_session_init(request) {#LocalCLIDebugWrapperSession.on_session_init}

Overrides on-session-init callback.

Args:
  • request: An instance of OnSessionInitRequest.
Returns:

An instance of OnSessionInitResponse.


tf_debug.LocalCLIDebugWrapperSession.partial_run(handle, fetches, feed_dict=None) {#LocalCLIDebugWrapperSession.partial_run}


tf_debug.LocalCLIDebugWrapperSession.partial_run_setup(fetches, feeds=None) {#LocalCLIDebugWrapperSession.partial_run_setup}

Sets up the feeds and fetches for partial runs in the session.


tf_debug.LocalCLIDebugWrapperSession.run(fetches, feed_dict=None, options=None, run_metadata=None) {#LocalCLIDebugWrapperSession.run}

Wrapper around Session.run() that inserts tensor watch options.

Args:
  • fetches: Same as the fetches arg to regular Session.run().
  • feed_dict: Same as the feed_dict arg to regular Session.run().
  • options: Same as the options arg to regular Session.run().
  • run_metadata: Same as the run_metadata arg to regular Session.run().
Returns:

Simply forwards the output of the wrapped Session.run() call.

Raises:
  • ValueError: On invalid OnRunStartAction value.

tf_debug.LocalCLIDebugWrapperSession.sess_str {#LocalCLIDebugWrapperSession.sess_str}


tf_debug.LocalCLIDebugWrapperSession.session {#LocalCLIDebugWrapperSession.session}