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


Python dcgan.generator方法代碼示例

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


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

示例1: test_generator_graph

# 需要導入模塊: from nets import dcgan [as 別名]
# 或者: from nets.dcgan import generator [as 別名]
def test_generator_graph(self):
    tf.set_random_seed(1234)
    # Check graph construction for a number of image size/depths and batch
    # sizes.
    for i, batch_size in zip(xrange(3, 7), xrange(3, 8)):
      tf.reset_default_graph()
      final_size = 2 ** i
      noise = tf.random_normal([batch_size, 64])
      image, end_points = dcgan.generator(
          noise,
          depth=32,
          final_size=final_size)

      self.assertAllEqual([batch_size, final_size, final_size, 3],
                          image.shape.as_list())

      expected_names = ['deconv%i' % j for j in xrange(1, i)] + ['logits']
      self.assertSetEqual(set(expected_names), set(end_points.keys()))

      # Check layer depths.
      for j in range(1, i):
        layer = end_points['deconv%i' % j]
        self.assertEqual(32 * 2**(i-j-1), layer.get_shape().as_list()[-1]) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:25,代碼來源:dcgan_test.py

示例2: test_generator_graph

# 需要導入模塊: from nets import dcgan [as 別名]
# 或者: from nets.dcgan import generator [as 別名]
def test_generator_graph(self):
    tf.set_random_seed(1234)
    # Check graph construction for a number of image size/depths and batch
    # sizes.
    for i, batch_size in zip(xrange(3, 7), xrange(3, 8)):
      tf.reset_default_graph()
      final_size = 2 ** i
      noise = tf.random.normal([batch_size, 64])
      image, end_points = dcgan.generator(
          noise,
          depth=32,
          final_size=final_size)

      self.assertAllEqual([batch_size, final_size, final_size, 3],
                          image.shape.as_list())

      expected_names = ['deconv%i' % j for j in xrange(1, i)] + ['logits']
      self.assertSetEqual(set(expected_names), set(end_points.keys()))

      # Check layer depths.
      for j in range(1, i):
        layer = end_points['deconv%i' % j]
        self.assertEqual(32 * 2**(i-j-1), layer.get_shape().as_list()[-1]) 
開發者ID:tensorflow,項目名稱:models,代碼行數:25,代碼來源:dcgan_test.py

示例3: test_generator_run

# 需要導入模塊: from nets import dcgan [as 別名]
# 或者: from nets.dcgan import generator [as 別名]
def test_generator_run(self):
    tf.set_random_seed(1234)
    noise = tf.random_normal([100, 64])
    image, _ = dcgan.generator(noise)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      image.eval() 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:9,代碼來源:dcgan_test.py

示例4: test_generator_invalid_input

# 需要導入模塊: from nets import dcgan [as 別名]
# 或者: from nets.dcgan import generator [as 別名]
def test_generator_invalid_input(self):
    wrong_dim_input = tf.zeros([5, 32, 32])
    with self.assertRaises(ValueError):
      dcgan.generator(wrong_dim_input)

    correct_input = tf.zeros([3, 2])
    with self.assertRaisesRegexp(ValueError, 'must be a power of 2'):
      dcgan.generator(correct_input, final_size=30)

    with self.assertRaisesRegexp(ValueError, 'must be greater than 8'):
      dcgan.generator(correct_input, final_size=4) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:13,代碼來源:dcgan_test.py


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