cntk.logging.graph module

Generic function that walks through the graph starting at root and uses function visitor on each node to check whether it should be returned.

Parameters:
  • root (Function or Variable) – the root to start the journey from
  • visitor (Python function or lambda) – function that takes a node as argument and returns True if that node should be returned.
  • depth (int, default 0) – how deep into the block hierarchy the DFS algorithm should go into. Set to -1 for infinite depth.
Returns:

List of functions, for which visitor was True

find_all_with_name(node, node_name, depth=0)[source]

Finds functions in the graph starting from node and doing a depth-first search.

Parameters:
  • node (Function or Variable) – the node to start the journey from
  • node_name (str) – name for which we are search nodes
  • depth (int, default 0) – how deep into the block hierarchy the DFS algorithm should go into. Set to -1 for infinite depth.
Returns:

List of primitive (or block) functions having the specified name

See also

find_all_with_name() in class Function.

find_by_name(node, node_name, depth=0)[source]

Finds a function in the graph starting from node and doing a depth-first search. It assumes that the name occurs only once.

Parameters:
  • node (Function or Variable) – the node to start the journey from
  • node_name (str) – name for which we are search nodes
  • depth (int, default 0) – how deep into the block hierarchy the DFS algorithm should go into. Set to -1 for infinite depth.
Returns:

Primitive (or block) function having the specified name

See also

find_by_name() in class Function.

find_by_uid(node, node_uid, depth=0)[source]

Finds a function in the graph based on its UID starting from node and doing a depth-first search. It assumes that the name occurs only once.

Parameters:
  • node (Function or Variable) – the node to start the journey from
  • node_uid (str or unicode (in Python 2)) – uid for which we are search nodes.
  • depth (int, default 0) – how deep into the block hierarchy the DFS algorithm should go into. Set to -1 for infinite depth.
Returns:

Primitive (or block) function having the specified name

See also

find_by_uid() in class Function.

get_node_outputs(node, depth=0)[source]

Walks through every node of the graph starting at node and returns a list of all node outputs.

Parameters:node (graph node) – the node to start the journey from
Returns:A list of all node outputs
plot(root, filename=None)[source]

Walks through every node of the graph starting at root, creates a network graph, and returns a network description. If filename is specified, it outputs a DOT, PNG, PDF, or SVG file depending on the file name’s suffix.

Requirements:

  • for DOT output: pydot_ng
  • for PNG, PDF, and SVG output: pydot_ng and graphviz (GraphViz executable has to be in the system’s PATH).
Parameters:
  • node (graph node) – the node to start the journey from
  • filename (str, default None) – file with extension ‘.dot’, ‘png’, ‘pdf’, or ‘svg’ to denote what format should be written. If None then nothing will be plotted, and the returned string can be used to debug the graph.
Returns:

str describing the graph