Closed WishMasterGit closed 4 years ago
Python Project/AlphaZero/utility/merge_model.py:
import tensorflow as tf
if __name__ == "__main__":
with tf.Session() as sess:
game_dir = "Gobang"
model_dir = "model2_10_10_5"
batch = "11000"
sess.run(tf.global_variables_initializer())
latest_ckpt = tf.train.latest_checkpoint("../" + game_dir + "/" + model_dir + "/" + batch)
restore_saver = tf.train.import_meta_graph("../" + game_dir + "/" + model_dir + "/" + batch + "/policy_value_net.model.meta")
restore_saver.restore(sess, latest_ckpt)
output_graph_def = tf.graph_util.convert_variables_to_constants(
sess, sess.graph_def, ["action_fc/LogSoftmax", "evaluation_fc2/Tanh"])
tf.train.write_graph(output_graph_def, "../" + game_dir + "/" + model_dir + "/" + batch, "graph.bytes", as_text=False)
This is the code that converts those files into one byte file.
Have a question, how did you converted models from tensorflow to bytes files in unity? Can't figure out this step. Because this code saves 4 files.