提交 02786176 authored 作者: carriepl's avatar carriepl

Merge pull request #2443 from nouiz/pydotprint

Pydotprint
...@@ -21,6 +21,7 @@ Montreal). ...@@ -21,6 +21,7 @@ Montreal).
News News
==== ====
* We support `cuDNN <http://deeplearning.net/software/theano/library/sandbox/cuda/dnn.html>`_ if it is installed by the user.
* Open Machine Learning Workshop 2014 `presentation <omlw2014/omlw_presentation.pdf>`_. * Open Machine Learning Workshop 2014 `presentation <omlw2014/omlw_presentation.pdf>`_.
* Colin Raffel `tutorial on Theano <http://nbviewer.ipython.org/github/craffel/theano-tutorial/blob/master/Theano%20Tutorial.ipynb>`_. * Colin Raffel `tutorial on Theano <http://nbviewer.ipython.org/github/craffel/theano-tutorial/blob/master/Theano%20Tutorial.ipynb>`_.
......
...@@ -623,6 +623,10 @@ def pydotprint(fct, outfile=None, ...@@ -623,6 +623,10 @@ def pydotprint(fct, outfile=None,
red ellipses are transfers from/to the gpu (ops with names GpuFromHost, red ellipses are transfers from/to the gpu (ops with names GpuFromHost,
HostFromGpu). HostFromGpu).
For edges, they are black by default. If a node returns a view
of an input, we put the corresponding input edge in blue. If it
returns a destroyed input, we put the corresponding edge in red.
.. note:: .. note::
Since October 20th, 2014, this print the inner function of all Since October 20th, 2014, this print the inner function of all
...@@ -800,6 +804,9 @@ def pydotprint(fct, outfile=None, ...@@ -800,6 +804,9 @@ def pydotprint(fct, outfile=None,
# Update the inputs that have an update function # Update the inputs that have an update function
input_update = {} input_update = {}
# Here outputs can be the original list, as we should not change
# it, we must copy it.
outputs = list(outputs)
if isinstance(fct, Function): if isinstance(fct, Function):
for i in reversed(fct.maker.expanded_inputs): for i in reversed(fct.maker.expanded_inputs):
if i.update is not None: if i.update is not None:
...@@ -838,6 +845,13 @@ def pydotprint(fct, outfile=None, ...@@ -838,6 +845,13 @@ def pydotprint(fct, outfile=None,
label = str(id) + ' ' + label label = str(id) + ' ' + label
if len(label) > max_label_size: if len(label) > max_label_size:
label = label[:max_label_size - 3] + '...' label = label[:max_label_size - 3] + '...'
param = {}
if hasattr(node.op, 'view_map') and id in reduce(
list.__add__, node.op.view_map.values(), []):
param['color'] = 'blue'
elif hasattr(node.op, 'destroy_map') and id in reduce(
list.__add__, node.op.destroy_map.values(), []):
param['color'] = 'red'
if var.owner is None: if var.owner is None:
if high_contrast: if high_contrast:
g.add_node(pd.Node(varstr, g.add_node(pd.Node(varstr,
...@@ -846,12 +860,12 @@ def pydotprint(fct, outfile=None, ...@@ -846,12 +860,12 @@ def pydotprint(fct, outfile=None,
shape=var_shape)) shape=var_shape))
else: else:
g.add_node(pd.Node(varstr, color='green', shape=var_shape)) g.add_node(pd.Node(varstr, color='green', shape=var_shape))
g.add_edge(pd.Edge(varstr, astr, label=label)) g.add_edge(pd.Edge(varstr, astr, label=label, **param))
elif var.name or not compact: elif var.name or not compact:
g.add_edge(pd.Edge(varstr, astr, label=label)) g.add_edge(pd.Edge(varstr, astr, label=label, **param))
else: else:
# no name, so we don't make a var ellipse # no name, so we don't make a var ellipse
g.add_edge(pd.Edge(apply_name(var.owner), astr, label=label)) g.add_edge(pd.Edge(apply_name(var.owner), astr, label=label, **param))
for id, var in enumerate(node.outputs): for id, var in enumerate(node.outputs):
varstr = var_name(var) varstr = var_name(var)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论