Hi all:
I tried to generate tf v1 graph and save to pb file in TF2.x, but found the graph is very different with what in TF1.x. Is there anyway can generate same pb in TF2.x?
with tf.compat.v1.Graph().as_default():
input_t = tf.compat.v1.placeholder(tf.float32, shape=(1, 28, 10))
gru_layer = tf.compat.v1.keras.layers.GRU(10, bias_initializer='glorot_uniform', reset_after=True)
out = gru_layer(inp)
with tf.compat.v1.Session() as sess:
sess.run(tf.compat.v1.global_variables_initializer())
frozen_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(sess, sess.graph_def, output_nodes)
with open(model_path, 'wb') as f:
f.write(frozen_graph_def.SerializeToString())
But in Netron, the graph as below:
Same code run in TF2.x:
Many EmptyTesorList in Graph.
Same Code run in TF1.x:
But if I saved to H5 file, the graph will be clear as below:
Anyone can explain this result? Or can we only use H5/SavedModel in tf2.x ?
Is there anyway can generate same pb in TF2.x?
Thanks all for your reply