def save_variables_and_metagraph(sess, saver, summary_writer, model_dir, model_name, step):
    print('Saving variables')
    start_time = time.time()
    checkpoint_path = os.path.join(model_dir, ('model-%s.ckpt' % model_name))
    saver.save(sess, checkpoint_path, global_step=step, write_meta_graph=False)
    save_time_variables = (time.time() - start_time)
    print(('Variables saved in %.2f seconds' % save_time_variables))
    metagraph_filename = os.path.join(model_dir, ('model-%s.meta' % model_name))
    save_time_metagraph = 0
    if (not os.path.exists(metagraph_filename)):
        print('Saving metagraph')
        start_time = time.time()
        saver.export_meta_graph(metagraph_filename)
        save_time_metagraph = (time.time() - start_time)
        print(('Metagraph saved in %.2f seconds' % save_time_metagraph))
    summary = tf.Summary()
    summary.value.add(tag='time/save_variables', simple_value=save_time_variables)
    summary.value.add(tag='time/save_metagraph', simple_value=save_time_metagraph)
    summary_writer.add_summary(summary, step)
def save_variables_and_metagraph(sess, saver, summary_writer, model_dir, model_name, step):
    print('Saving variables')
    start_time = time.time()
    checkpoint_path = os.path.join(model_dir, ('model-%s.ckpt' % model_name))
    saver.save(sess, checkpoint_path, global_step=step, write_meta_graph=False)
    save_time_variables = (time.time() - start_time)
    print(('Variables saved in %.2f seconds' % save_time_variables))
    metagraph_filename = os.path.join(model_dir, ('model-%s.meta' % model_name))
    save_time_metagraph = 0
    if (not os.path.exists(metagraph_filename)):
        print('Saving metagraph')
        start_time = time.time()
        saver.export_meta_graph(metagraph_filename)
        save_time_metagraph = (time.time() - start_time)
        print(('Metagraph saved in %.2f seconds' % save_time_metagraph))
    summary = tf.Summary()
    summary.value.add(tag='time/save_variables', simple_value=save_time_variables)
    summary.value.add(tag='time/save_metagraph', simple_value=save_time_metagraph)
    summary_writer.add_summary(summary, step)