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


Python util.get_eval_noise_continuous_dim2方法代碼示例

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


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

示例1: main

# 需要導入模塊: import util [as 別名]
# 或者: from util import get_eval_noise_continuous_dim2 [as 別名]
def main(_, run_eval_loop=True):
  with tf.name_scope('inputs'):
    noise_args = (FLAGS.noise_samples, CAT_SAMPLE_POINTS, CONT_SAMPLE_POINTS,
                  FLAGS.unstructured_noise_dims, FLAGS.continuous_noise_dims)
    # Use fixed noise vectors to illustrate the effect of each dimension.
    display_noise1 = util.get_eval_noise_categorical(*noise_args)
    display_noise2 = util.get_eval_noise_continuous_dim1(*noise_args)
    display_noise3 = util.get_eval_noise_continuous_dim2(*noise_args)
    _validate_noises([display_noise1, display_noise2, display_noise3])

  # Visualize the effect of each structured noise dimension on the generated
  # image.
  generator_fn = lambda x: networks.infogan_generator(x, len(CAT_SAMPLE_POINTS))
  with tf.variable_scope('Generator') as genscope:  # Same scope as in training.
    categorical_images = generator_fn(display_noise1)
  reshaped_categorical_img = tfgan.eval.image_reshaper(
      categorical_images, num_cols=len(CAT_SAMPLE_POINTS))
  tf.summary.image('categorical', reshaped_categorical_img, max_outputs=1)

  with tf.variable_scope(genscope, reuse=True):
    continuous1_images = generator_fn(display_noise2)
  reshaped_continuous1_img = tfgan.eval.image_reshaper(
      continuous1_images, num_cols=len(CONT_SAMPLE_POINTS))
  tf.summary.image('continuous1', reshaped_continuous1_img, max_outputs=1)

  with tf.variable_scope(genscope, reuse=True):
    continuous2_images = generator_fn(display_noise3)
  reshaped_continuous2_img = tfgan.eval.image_reshaper(
      continuous2_images, num_cols=len(CONT_SAMPLE_POINTS))
  tf.summary.image('continuous2', reshaped_continuous2_img, max_outputs=1)

  # Evaluate image quality.
  all_images = tf.concat(
      [categorical_images, continuous1_images, continuous2_images], 0)
  tf.summary.scalar('MNIST_Classifier_score',
                    util.mnist_score(all_images, FLAGS.classifier_filename))

  # Write images to disk.
  image_write_ops = []
  image_write_ops.append(_get_write_image_ops(
      FLAGS.eval_dir, 'categorical_infogan.png', reshaped_categorical_img[0]))
  image_write_ops.append(_get_write_image_ops(
      FLAGS.eval_dir, 'continuous1_infogan.png', reshaped_continuous1_img[0]))
  image_write_ops.append(_get_write_image_ops(
      FLAGS.eval_dir, 'continuous2_infogan.png', reshaped_continuous2_img[0]))

  # For unit testing, use `run_eval_loop=False`.
  if not run_eval_loop: return
  tf.contrib.training.evaluate_repeatedly(
      FLAGS.checkpoint_dir,
      hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir),
             tf.contrib.training.StopAfterNEvalsHook(1)],
      eval_ops=image_write_ops,
      max_number_of_evaluations=FLAGS.max_number_of_evaluations) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:56,代碼來源:infogan_eval.py

示例2: main

# 需要導入模塊: import util [as 別名]
# 或者: from util import get_eval_noise_continuous_dim2 [as 別名]
def main(_, run_eval_loop=True):
  with tf.name_scope('inputs'):
    noise_args = (FLAGS.noise_samples, CAT_SAMPLE_POINTS, CONT_SAMPLE_POINTS,
                  FLAGS.unstructured_noise_dims, FLAGS.continuous_noise_dims)
    # Use fixed noise vectors to illustrate the effect of each dimension.
    display_noise1 = util.get_eval_noise_categorical(*noise_args)
    display_noise2 = util.get_eval_noise_continuous_dim1(*noise_args)
    display_noise3 = util.get_eval_noise_continuous_dim2(*noise_args)
    _validate_noises([display_noise1, display_noise2, display_noise3])

  # Visualize the effect of each structured noise dimension on the generated
  # image.
  def generator_fn(inputs):
    return networks.infogan_generator(
        inputs, len(CAT_SAMPLE_POINTS), is_training=False)
  with tf.variable_scope('Generator') as genscope:  # Same scope as in training.
    categorical_images = generator_fn(display_noise1)
  reshaped_categorical_img = tfgan.eval.image_reshaper(
      categorical_images, num_cols=len(CAT_SAMPLE_POINTS))
  tf.summary.image('categorical', reshaped_categorical_img, max_outputs=1)

  with tf.variable_scope(genscope, reuse=True):
    continuous1_images = generator_fn(display_noise2)
  reshaped_continuous1_img = tfgan.eval.image_reshaper(
      continuous1_images, num_cols=len(CONT_SAMPLE_POINTS))
  tf.summary.image('continuous1', reshaped_continuous1_img, max_outputs=1)

  with tf.variable_scope(genscope, reuse=True):
    continuous2_images = generator_fn(display_noise3)
  reshaped_continuous2_img = tfgan.eval.image_reshaper(
      continuous2_images, num_cols=len(CONT_SAMPLE_POINTS))
  tf.summary.image('continuous2', reshaped_continuous2_img, max_outputs=1)

  # Evaluate image quality.
  all_images = tf.concat(
      [categorical_images, continuous1_images, continuous2_images], 0)
  tf.summary.scalar('MNIST_Classifier_score',
                    util.mnist_score(all_images, FLAGS.classifier_filename))

  # Write images to disk.
  image_write_ops = []
  if FLAGS.write_to_disk:
    image_write_ops.append(_get_write_image_ops(
        FLAGS.eval_dir, 'categorical_infogan.png', reshaped_categorical_img[0]))
    image_write_ops.append(_get_write_image_ops(
        FLAGS.eval_dir, 'continuous1_infogan.png', reshaped_continuous1_img[0]))
    image_write_ops.append(_get_write_image_ops(
        FLAGS.eval_dir, 'continuous2_infogan.png', reshaped_continuous2_img[0]))

  # For unit testing, use `run_eval_loop=False`.
  if not run_eval_loop: return
  tf.contrib.training.evaluate_repeatedly(
      FLAGS.checkpoint_dir,
      hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir),
             tf.contrib.training.StopAfterNEvalsHook(1)],
      eval_ops=image_write_ops,
      max_number_of_evaluations=FLAGS.max_number_of_evaluations) 
開發者ID:itsamitgoel,項目名稱:Gun-Detector,代碼行數:59,代碼來源:infogan_eval.py


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