Skip to content

Commit

Permalink
fix layer/node topo sort problem (#2433)
Browse files Browse the repository at this point in the history
* fix layer/node topo sort problem

* fix to only iterate over valid layer/node keys
  • Loading branch information
Philip-Bachman authored and fchollet committed Apr 21, 2016
1 parent 4680d70 commit ad49962
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion keras/engine/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,8 @@ def build_map_of_graph(tensor, seen_nodes=set(), depth=0,
layers_by_depth[depth] = []
layers_by_depth[depth].append(layer)

depth_keys = list(nodes_by_depth.keys())
# get sorted list of layer depths
depth_keys = list(layers_by_depth.keys())
depth_keys.sort(reverse=True)

# set self.layers and self.layers_by_depth
Expand All @@ -1686,6 +1687,10 @@ def build_map_of_graph(tensor, seen_nodes=set(), depth=0,
self.layers = layers
self.layers_by_depth = layers_by_depth

# get sorted list of node depths
depth_keys = list(nodes_by_depth.keys())
depth_keys.sort(reverse=True)

# check that all tensors required are computable.
# computable_tensors: all tensors in the graph
# that can be computed from the inputs provided
Expand Down

0 comments on commit ad49962

Please sign in to comment.