Last active
October 17, 2017 14:27
-
-
Save dkurt/ff1b2dd272e544e6873c54d3a571662a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
# Read the graph. | |
with tf.gfile.FastGFile('opt_graph.pb') as f: | |
graph_def = tf.GraphDef() | |
graph_def.ParseFromString(f.read()) | |
# Remove Const nodes. | |
for i in reversed(range(len(graph_def.node))): | |
if graph_def.node[i].op == 'Const': | |
del graph_def.node[i] | |
for attr in ['T', 'data_format', 'Tshape', 'N', 'Tidx', 'Tdim', | |
'use_cudnn_on_gpu', 'Index', 'Tperm', 'is_training', | |
'Tpaddings']: | |
if attr in graph_def.node[i].attr: | |
del graph_def.node[i].attr[attr] | |
# Save as text. | |
tf.train.write_graph(graph_def, "", "text_graph.pbtxt", as_text=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment