parameters: (caffe_net, rankdir, label_edges=True, phase=None)
return_statement: return pydot_graph
docstring: Create a data structure which represents the `caffe_net`.
  
      Parameters
      ----------
      caffe_net : object
      rankdir : {'LR', 'TB', 'BT'}
          Direction of graph layout.
      label_edges : boolean, optional
          Label the edges (default is True).
      phase : {caffe_pb2.Phase.TRAIN, caffe_pb2.Phase.TEST, None} optional
          Include layers from this network phase.  If None, include all layers.
          (the default is None)
  
      Returns
      -------
      pydot graph object
docstring_summary: Create a data structure which represents the `caffe_net`.
docstring_tokens: Create a data structure which represents the caffe_net .
function: def get_pydot_graph(caffe_net, rankdir, label_edges=True, phase=None):
      """Create a data structure which represents the `caffe_net`.
  
      Parameters
      ----------
      caffe_net : object
      rankdir : {'LR', 'TB', 'BT'}
          Direction of graph layout.
      label_edges : boolean, optional
          Label the edges (default is True).
      phase : {caffe_pb2.Phase.TRAIN, caffe_pb2.Phase.TEST, None} optional
          Include layers from this network phase.  If None, include all layers.
          (the default is None)
  
      Returns
      -------
      pydot graph object
      """
      pydot_graph = pydot.Dot(caffe_net.name if caffe_net.name else 'Net',
                              graph_type='digraph',
                              rankdir=rankdir)
      pydot_nodes = {}
      pydot_edges = []
      for layer in caffe_net.layer:
          if phase is not None:
            included = False
            if len(layer.include) == 0:
              included = True
            if len(layer.include) > 0 and len(layer.exclude) > 0:
              raise ValueError('layer ' + layer.name + ' has both include '
                               'and exclude specified.')
            for layer_phase in layer.include:
              included = included or layer_phase.phase == phase
            for layer_phase in layer.exclude:
              included = included and not layer_phase.phase == phase
            if not included:
              continue
          node_label = get_layer_label(layer, rankdir)
          node_name = "%s_%s" % (layer.name, layer.type)
          if (len(layer.bottom) == 1 and len(layer.top) == 1 and
             layer.bottom[0] == layer.top[0]):
              # We have an in-place neuron layer.
              pydot_nodes[node_name] = pydot.Node(node_label,
                                                  **NEURON_LAYER_STYLE)
          else:
              layer_style = LAYER_STYLE_DEFAULT
              layer_style['fillcolor'] = choose_color_by_layertype(layer.type)
              pydot_nodes[node_name] = pydot.Node(node_label, **layer_style)
          for bottom_blob in layer.bottom:
              pydot_nodes[bottom_blob + '_blob'] = pydot.Node('%s' % bottom_blob,
                                                              **BLOB_STYLE)
              edge_label = '""'
              pydot_edges.append({'src': bottom_blob + '_blob',
                                  'dst': node_name,
                                  'label': edge_label})
          for top_blob in layer.top:
              pydot_nodes[top_blob + '_blob'] = pydot.Node('%s' % (top_blob))
              if label_edges:
                  edge_label = get_edge_label(layer)
              else:
                  edge_label = '""'
              pydot_edges.append({'src': node_name,
                                  'dst': top_blob + '_blob',
                                  'label': edge_label})
      # Now, add the nodes and edges to the graph.
      for node in pydot_nodes.values():
          pydot_graph.add_node(node)
      for edge in pydot_edges:
          pydot_graph.add_edge(
              pydot.Edge(pydot_nodes[edge['src']],
                         pydot_nodes[edge['dst']],
                         label=edge['label']))
      return pydot_graph
function_tokens: def get_pydot_graph ( caffe_net , rankdir , label_edges = True , phase = None ) : pydot_graph = pydot . Dot ( caffe_net . name if caffe_net . name else 'Net' , graph_type = 'digraph' , rankdir = rankdir ) pydot_nodes = { } pydot_edges = [ ] for layer in caffe_net . layer : if phase is not None : included = False if len ( layer . include ) == 0 : included = True if len ( layer . include ) > 0 and len ( layer . exclude ) > 0 : raise ValueError ( 'layer ' + layer . name + ' has both include ' 'and exclude specified.' ) for layer_phase in layer . include : included = included or layer_phase . phase == phase for layer_phase in layer . exclude : included = included and not layer_phase . phase == phase if not included : continue node_label = get_layer_label ( layer , rankdir ) node_name = "%s_%s" % ( layer . name , layer . type ) if ( len ( layer . bottom ) == 1 and len ( layer . top ) == 1 and layer . bottom [ 0 ] == layer . top [ 0 ] ) : # We have an in-place neuron layer. pydot_nodes [ node_name ] = pydot . Node ( node_label , * * NEURON_LAYER_STYLE ) else : layer_style = LAYER_STYLE_DEFAULT layer_style [ 'fillcolor' ] = choose_color_by_layertype ( layer . type ) pydot_nodes [ node_name ] = pydot . Node ( node_label , * * layer_style ) for bottom_blob in layer . bottom : pydot_nodes [ bottom_blob + '_blob' ] = pydot . Node ( '%s' % bottom_blob , * * BLOB_STYLE ) edge_label = '""' pydot_edges . append ( { 'src' : bottom_blob + '_blob' , 'dst' : node_name , 'label' : edge_label } ) for top_blob in layer . top : pydot_nodes [ top_blob + '_blob' ] = pydot . Node ( '%s' % ( top_blob ) ) if label_edges : edge_label = get_edge_label ( layer ) else : edge_label = '""' pydot_edges . append ( { 'src' : node_name , 'dst' : top_blob + '_blob' , 'label' : edge_label } ) # Now, add the nodes and edges to the graph. for node in pydot_nodes . values ( ) : pydot_graph . add_node ( node ) for edge in pydot_edges : pydot_graph . add_edge ( pydot . Edge ( pydot_nodes [ edge [ 'src' ] ] , pydot_nodes [ edge [ 'dst' ] ] , label = edge [ 'label' ] ) ) return pydot_graph