當前位置: 首頁>>代碼示例>>Python>>正文


Python tensorflow.InvalidArgumentError方法代碼示例

本文整理匯總了Python中tensorflow.InvalidArgumentError方法的典型用法代碼示例。如果您正苦於以下問題:Python tensorflow.InvalidArgumentError方法的具體用法?Python tensorflow.InvalidArgumentError怎麽用?Python tensorflow.InvalidArgumentError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow的用法示例。


在下文中一共展示了tensorflow.InvalidArgumentError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_once

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import InvalidArgumentError [as 別名]
def run_once(model, losses, weights, saver, summary_writer, summary_op):
  """Evaluates the latest model checkpoint.

  Args:
    model: Instance of SkipThoughtsModel; the model to evaluate.
    losses: Tensor; the target cross entropy losses for the current batch.
    weights: A Tensor of weights corresponding to losses.
    saver: Instance of tf.train.Saver for restoring model Variables.
    summary_writer: Instance of FileWriter.
    summary_op: Op for generating model summaries.
  """
  model_path = tf.train.latest_checkpoint(FLAGS.checkpoint_dir)
  if not model_path:
    tf.logging.info("Skipping evaluation. No checkpoint found in: %s",
                    FLAGS.checkpoint_dir)
    return

  with tf.Session() as sess:
    # Load model from checkpoint.
    tf.logging.info("Loading model from checkpoint: %s", model_path)
    saver.restore(sess, model_path)
    global_step = tf.train.global_step(sess, model.global_step.name)
    tf.logging.info("Successfully loaded %s at global step = %d.",
                    os.path.basename(model_path), global_step)
    if global_step < FLAGS.min_global_step:
      tf.logging.info("Skipping evaluation. Global step = %d < %d", global_step,
                      FLAGS.min_global_step)
      return

    # Start the queue runners.
    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)

    num_eval_batches = int(
        math.ceil(FLAGS.num_eval_examples / model.config.batch_size))

    # Run evaluation on the latest checkpoint.
    try:
      evaluate_model(sess, losses, weights, num_eval_batches, global_step,
                     summary_writer, summary_op)
    except tf.InvalidArgumentError:
      tf.logging.error(
          "Evaluation raised InvalidArgumentError (e.g. due to Nans).")
    finally:
      coord.request_stop()
      coord.join(threads, stop_grace_period_secs=10) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:48,代碼來源:track_perplexity.py

示例2: run_once

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import InvalidArgumentError [as 別名]
def run_once(model, losses, weights, saver, summary_writer, summary_op):
    """Evaluates the latest model checkpoint.

    Args:
      model: Instance of SkipThoughtsModel; the model to evaluate.
      losses: Tensor; the target cross entropy losses for the current batch.
      weights: A Tensor of weights corresponding to losses.
      saver: Instance of tf.train.Saver for restoring model Variables.
      summary_writer: Instance of FileWriter.
      summary_op: Op for generating model summaries.
    """
    model_path = tf.train.latest_checkpoint(FLAGS.checkpoint_dir)
    if not model_path:
        tf.logging.info("Skipping evaluation. No checkpoint found in: %s",
                        FLAGS.checkpoint_dir)
        return

    with tf.Session() as sess:
        # Load model from checkpoint.
        tf.logging.info("Loading model from checkpoint: %s", model_path)
        saver.restore(sess, model_path)
        global_step = tf.train.global_step(sess, model.global_step.name)
        tf.logging.info("Successfully loaded %s at global step = %d.",
                        os.path.basename(model_path), global_step)
        if global_step < FLAGS.min_global_step:
            tf.logging.info("Skipping evaluation. Global step = %d < %d",
                            global_step,
                            FLAGS.min_global_step)
            return

        # Start the queue runners.
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)

        num_eval_batches = int(
            math.ceil(FLAGS.num_eval_examples / model.config.batch_size))

        # Run evaluation on the latest checkpoint.
        try:
            evaluate_model(sess, losses, weights, num_eval_batches, global_step,
                           summary_writer, summary_op)
        except tf.InvalidArgumentError:
            tf.logging.error(
                "Evaluation raised InvalidArgumentError (e.g. due to Nans).")
        finally:
            coord.request_stop()
            coord.join(threads, stop_grace_period_secs=10) 
開發者ID:snuspl,項目名稱:parallax,代碼行數:49,代碼來源:track_perplexity.py


注:本文中的tensorflow.InvalidArgumentError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。