Skip to content

Commit 6f1cbcb

Browse files
authored
Avoid failing directly when parsng Keras 2 layers (#6826)
Currently inbound node parsing is not backward compatible with Keras 2. Instead of failing directly, changed the code to return empty inbound node results. Googlers, see the description in cl/622948159 for context. Tested internally: cl/582334596 #keras3 #oncall
1 parent 7d8f682 commit 6f1cbcb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tensorboard/plugins/graph/keras_util.py

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ def _get_inbound_nodes(layer):
122122
inbound_nodes = []
123123
if layer.get("inbound_nodes") is not None:
124124
for maybe_inbound_node in layer.get("inbound_nodes", []):
125+
if not isinstance(maybe_inbound_node, dict):
126+
# Note that the inbound node parsing is not backward compatible with
127+
# Keras 2. If given a Keras 2 model, the input nodes will be missing
128+
# in the final graph.
129+
continue
125130
for inbound_node_args in maybe_inbound_node.get("args", []):
126131
# Sometimes this field is a list when there are multiple inbound nodes
127132
# for the given layer.

0 commit comments

Comments
 (0)