Switches to OrderedDict to make the dictionary order deterministic so we have less randomness from graph building.
PiperOrigin-RevId: 167755072
This commit is contained in:
parent
acc7c00588
commit
ca65468a02
@ -198,7 +198,11 @@ def _features_to_raw_params(features, types):
|
||||
sparse_types = []
|
||||
dense_keys = []
|
||||
dense_types = []
|
||||
dense_defaults = {}
|
||||
# When the graph is built twice, multiple dense_defaults in a normal dict
|
||||
# could come out in different orders. This will fail the _e2e_test which
|
||||
# expects exactly the same graph.
|
||||
# OrderedDict which preserves the order can solve the problem.
|
||||
dense_defaults = collections.OrderedDict()
|
||||
dense_shapes = []
|
||||
if features:
|
||||
# NOTE: We iterate over sorted keys to keep things deterministic.
|
||||
@ -624,7 +628,8 @@ def _parse_example_raw(serialized,
|
||||
"""
|
||||
with ops.name_scope(name, "ParseExample", [serialized, names]):
|
||||
names = [] if names is None else names
|
||||
dense_defaults = {} if dense_defaults is None else dense_defaults
|
||||
dense_defaults = collections.OrderedDict(
|
||||
) if dense_defaults is None else dense_defaults
|
||||
sparse_keys = [] if sparse_keys is None else sparse_keys
|
||||
sparse_types = [] if sparse_types is None else sparse_types
|
||||
dense_keys = [] if dense_keys is None else dense_keys
|
||||
|
Loading…
x
Reference in New Issue
Block a user