Skip to content

Instantly share code, notes, and snippets.

@walsvid
Created August 18, 2019 05:51
Show Gist options
  • Save walsvid/e5995b575d2eb982f679c15063f3c1fa to your computer and use it in GitHub Desktop.
Save walsvid/e5995b575d2eb982f679c15063f3c1fa to your computer and use it in GitHub Desktop.
tensorflow save的时候改名
def rename(self, sess=None, ckpt_path=None, step=None):
# if not sess:
# raise AttributeError('TensorFlow session not provided.')
# print(self.vars)
new_vars = {}
for k,v in self.vars.items():
new_vars[k.replace('meshnet','meshnetmvp2m')] = v
saver = tf.train.Saver(new_vars, max_to_keep=0)
save_path = saver.save(sess, os.path.join(ckpt_path, 'new', '{}.ckpt'.format(self.name)), global_step=step)
print('Model saved in file: {}, epoch {}'.format(save_path, step))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment