Skip to content

Commit

Permalink
workaround for constant nodes (#139)
Browse files Browse the repository at this point in the history
* workaround for constant nodes

see #138

* workaround for constant node

* Update graph.py

specifies the exact exception.
  • Loading branch information
jhg543 authored and lanpa committed May 8, 2018
1 parent 87eee66 commit ee35e97
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tensorboardX/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .src.tensor_shape_pb2 import TensorShapeProto

from distutils.version import LooseVersion
import warnings


def parse(graph):
Expand Down Expand Up @@ -32,8 +33,12 @@ def parse(graph):
nodes.append({'name': uname, 'op': 'output', 'inputs': [n.uniqueName()], 'attr': 'output'})

for n in graph.nodes():
attrs = {k: n[k] for k in n.attributeNames()}
attrs = str(attrs).replace("'", ' ') # singlequote will be escaped by tensorboard
try:
attrs = str({k: n[k] for k in n.attributeNames()})
except RuntimeError as e:
attrs = str(n).strip()
warnings.warn("Error getting attributes of node {}, error is {}".format(attrs, e))
attrs = attrs.replace("'", ' ') # singlequote will be escaped by tensorboard
inputs = [i.uniqueName() for i in n.inputs()]
outputnode = next(iter(n.outputs())) # FIXME: only first output is considered (only Dropout)
uname = outputnode.uniqueName()
Expand Down

0 comments on commit ee35e97

Please sign in to comment.