Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2661eb9

Browse files
author
Taylor Robie
authored
change reference_data.py to use tf.gfile (tensorflow#3921)
* change reference_data.py to use tf.gfile * simplify json treatment * Update reference files to account for a superficial change in batch_norm
1 parent c93409c commit 2661eb9

File tree

43 files changed

+23
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+23
-23
lines changed

official/utils/testing/reference_data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _construct_and_save_reference_files(
170170
# Serialize graph for comparison.
171171
graph_bytes = graph.as_graph_def().SerializeToString()
172172
expected_file = os.path.join(data_dir, "expected_graph")
173-
with open(expected_file, "wb") as f:
173+
with tf.gfile.Open(expected_file, "wb") as f:
174174
f.write(graph_bytes)
175175

176176
with graph.as_default():
@@ -191,10 +191,10 @@ def _construct_and_save_reference_files(
191191

192192
if correctness_function is not None:
193193
results = correctness_function(*eval_results)
194-
with open(os.path.join(data_dir, "results.json"), "wt") as f:
194+
with tf.gfile.Open(os.path.join(data_dir, "results.json"), "w") as f:
195195
json.dump(results, f)
196196

197-
with open(os.path.join(data_dir, "tf_version.json"), "wt") as f:
197+
with tf.gfile.Open(os.path.join(data_dir, "tf_version.json"), "w") as f:
198198
json.dump([tf.VERSION, tf.GIT_VERSION], f)
199199

200200
def _evaluate_test_case(self, name, graph, ops_to_eval, correctness_function):
@@ -216,7 +216,7 @@ def _evaluate_test_case(self, name, graph, ops_to_eval, correctness_function):
216216
# Serialize graph for comparison.
217217
graph_bytes = graph.as_graph_def().SerializeToString()
218218
expected_file = os.path.join(data_dir, "expected_graph")
219-
with open(expected_file, "rb") as f:
219+
with tf.gfile.Open(expected_file, "rb") as f:
220220
expected_graph_bytes = f.read()
221221
# The serialization is non-deterministic byte-for-byte. Instead there is
222222
# a utility which evaluates the semantics of the two graphs to test for
@@ -231,7 +231,7 @@ def _evaluate_test_case(self, name, graph, ops_to_eval, correctness_function):
231231
init = tf.global_variables_initializer()
232232
saver = tf.train.Saver()
233233

234-
with open(os.path.join(data_dir, "tf_version.json"), "rt") as f:
234+
with tf.gfile.Open(os.path.join(data_dir, "tf_version.json"), "r") as f:
235235
tf_version_reference, tf_git_version_reference = json.load(f) # pylint: disable=unpacking-non-sequence
236236

237237
tf_version_comparison = ""
@@ -262,7 +262,7 @@ def _evaluate_test_case(self, name, graph, ops_to_eval, correctness_function):
262262
eval_results = [op.eval() for op in ops_to_eval]
263263
if correctness_function is not None:
264264
results = correctness_function(*eval_results)
265-
with open(os.path.join(data_dir, "results.json"), "rt") as f:
265+
with tf.gfile.Open(os.path.join(data_dir, "results.json"), "r") as f:
266266
expected_results = json.load(f)
267267
self.assertAllClose(results, expected_results)
268268

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.08920872211456299, 0.8918969631195068, 4064.7060546875, 32, 4, 4, 8, 0.0, 0.8524793982505798, 2294.368896484375]
1+
[32, 8, 8, 4, 0.08920872211456299, 0.8918969631195068, 4064.7060546875, 32, 4, 4, 8, 0.0, 0.10715862363576889, 2344.4775390625]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.918815016746521, 0.1826801300048828, 4064.4677734375, 32, 4, 4, 8, -1.6396304368972778, 0.00014326802920550108, 98.39237213134766]
1+
[32, 8, 8, 4, 0.918815016746521, 0.1826801300048828, 4064.4677734375, 32, 4, 4, 8, -1.3153012990951538, 0.011247094720602036, 261.84716796875]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.1677999496459961, 0.7767924070358276, 4089.44189453125, 32, 8, 8, 4, 1.8148397207260132, 1.3842545747756958, 5515.17529296875]
1+
[32, 8, 8, 4, 0.1677999496459961, 0.7767924070358276, 4089.44189453125, 32, 8, 8, 4, 0.8615571856498718, 1.1359407901763916, 5806.876953125]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.8239736557006836, 0.3485994338989258, 4108.87548828125, 32, 8, 8, 4, 0.8239736557006836, 0.3485994338989258, 1519.11328125]
1+
[32, 8, 8, 4, 0.8239736557006836, 0.3485994338989258, 4108.87548828125, 32, 8, 8, 4, 0.16798323392868042, -0.2975311279296875, 2860.068359375]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.5349493026733398, 0.5126370191574097, 4070.01220703125, 32, 4, 4, 8, 0.0, 1.4142168760299683, 2306.740478515625]
1+
[32, 8, 8, 4, 0.5349493026733398, 0.5126370191574097, 4070.01220703125, 32, 4, 4, 8, 0.0, 2.7680201530456543, 2341.23486328125]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.7820245027542114, 0.8173515796661377, 4095.256591796875, 32, 4, 4, 8, -0.3681173324584961, 0.197183296084404, 213.7501678466797]
1+
[32, 8, 8, 4, 0.7820245027542114, 0.8173515796661377, 4095.256591796875, 32, 4, 4, 8, 0.0679062008857727, 0.009305447340011597, -137.36178588867188]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.23128163814544678, 0.22117376327514648, 4100.51806640625, 32, 8, 8, 4, 0.9646798372268677, 0.16614516079425812, 5799.6708984375]
1+
[32, 8, 8, 4, 0.23128163814544678, 0.22117376327514648, 4100.51806640625, 32, 8, 8, 4, 1.1768392324447632, 0.2728465795516968, 5832.6416015625]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[32, 8, 8, 4, 0.7616699934005737, 0.5485763549804688, 4106.8720703125, 32, 8, 8, 4, 0.42806127667427063, 0.7305102348327637, 5319.9892578125]
1+
[32, 8, 8, 4, 0.7616699934005737, 0.5485763549804688, 4106.8720703125, 32, 8, 8, 4, -0.056346118450164795, 0.5792689919471741, 2972.37255859375]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["1.8.0-dev20180325", "v1.7.0-rc1-750-g6c1737e6c8"]
1+
["1.8.0-dev20180408", "v1.7.0-1345-gb874783ccd"]

0 commit comments

Comments
 (0)