def WriteCheckpointFile(net, t_op, best=False):
  """Writes out the model to disk."""
  ckpt_dir = os.path.join(t_op.checkpoint_prefix, t_op.checkpoint_directory)
  if not os.path.isdir(ckpt_dir):
    os.makedirs(ckpt_dir)
  if best:
    tag = 'BEST'
    checkpoint_file = '%s_%s' % (net.name, tag)
    checkpoint_file = os.path.join(ckpt_dir, checkpoint_file)
    print 'Writing current best model %s' % checkpoint_file
    f = gzip.open(checkpoint_file, 'wb')
    f.write(net.SerializeToString())
    f.close()
  else:
    tag = 'LAST'
    checkpoint_file = '%s_%s' % (net.name, time.strftime('%s'))
    checkpoint_file = os.path.join(ckpt_dir, checkpoint_file)
    print 'Writing checkpoint %s' % checkpoint_file
    f = gzip.open(checkpoint_file, 'wb')
    f.write(net.SerializeToString())
    f.close()
    checkpoint_file_LAST = '%s_%s' % (net.name, tag)
    checkpoint_file_LAST = os.path.join(ckpt_dir, checkpoint_file_LAST)
    shutil.copyfile(checkpoint_file, checkpoint_file_LAST)

  # Save the t_op.
  checkpoint_file_op = '%s_train_op_%s' % (net.name, tag)
  checkpoint_file = os.path.join(ckpt_dir, checkpoint_file_op)
  f = gzip.open(checkpoint_file, 'wb')
  f.write(t_op.SerializeToString())
  f.close()
Writes out the model to disk.
deepnet/util.py