Skip to content

Commit 694886f

Browse files
committed
remove Identity block
1 parent 486447d commit 694886f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

examples/mnist/expected_values.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8487935e-05, 5.188386e-08, 0.0003525585, 0.0014435184, 3.3050244e-07, 3.180701e-05, 2.4361995e-08, 0.9980293, 1.7698758e-05, 0.00010610428
1+
4.0609893e-06, 1.1228256e-07, 4.821958e-05, 0.00013738014, 4.2588137e-09, 2.3615916e-05, 1.6721445e-10, 0.99975353, 7.9972335e-07, 3.221138e-05

examples/mnist/mnist.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ def probability_model(x):
5858
assert_array_equal(expected, tf_model_output)
5959
assert_array_equal(expected, frozen_model_output[0])
6060

61+
# Remove `Identity` operation
62+
# # TODO Check whether the last identity operation is actualy required
63+
frozen_model_graph_def = frozen_model.graph.as_graph_def()
64+
optimized_graph_def = tf.Graph().as_graph_def()
65+
optimized_graph_def.node.extend(frozen_model_graph_def.node[:-1])
66+
6167
# write the computation graph and weights
6268
directory = "examples/mnist"
63-
tf.io.write_graph(frozen_model.graph, directory, "model.pb", as_text=False)
69+
tf.io.write_graph(optimized_graph_def, directory, "model.pb", as_text=False)
6470

6571
# dump expected values to compare Rust's outputs
6672
with open("examples/mnist/expected_values.txt", "w") as f:
@@ -71,4 +77,4 @@ def probability_model(x):
7177
logdir = "logs/mnist"
7278
writer = tf.summary.create_file_writer(logdir)
7379
with writer.as_default():
74-
tf.summary.graph(frozen_model.graph)
80+
tf.summary.graph(optimized_graph_def)

examples/mnist/model.pb

-218 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)