本文整理匯總了Python中model.ckpt方法的典型用法代碼示例。如果您正苦於以下問題:Python model.ckpt方法的具體用法?Python model.ckpt怎麽用?Python model.ckpt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類model
的用法示例。
在下文中一共展示了model.ckpt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_checkpoint_num
# 需要導入模塊: import model [as 別名]
# 或者: from model import ckpt [as 別名]
def get_checkpoint_num(checkpoint_path):
m = re.match('^/.+model.ckpt-([0-9]+)$', checkpoint_path)
return int(m.group(1))
示例2: eval_once
# 需要導入模塊: import model [as 別名]
# 或者: from model import ckpt [as 別名]
def eval_once(saver, top_k_op):
"""Run Eval once.
Args:
saver: Saver.
summary_writer: Summary writer.
top_k_op: Top K op.
"""
with tf.Session() as sess:
ckpt = tf.train.get_checkpoint_state(FLAGS.checkpoint_dir)
if ckpt and ckpt.model_checkpoint_path:
# Restores from checkpoint
saver.restore(sess, ckpt.model_checkpoint_path)
# Assuming model_checkpoint_path looks something like:
# /my-favorite-path/MNIST_train/model.ckpt-0,
# extract global_step from it.
global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[
-1]
else:
print('No checkpoint file found')
return
predictions = np.sum(sess.run([top_k_op]))
# Compute precision.
print('%s: precision = %.3f' % (datetime.now(), predictions))